Why Automate with Python?
Python is widely regarded as the best language for automation — its readable syntax, massive standard library, and vast ecosystem of third-party packages make it ideal for scripting everyday tasks. If you find yourself doing the same thing more than twice, it's worth automating.
Here are five real-world tasks you can automate with relatively simple Python scripts.
1. Renaming and Organizing Files
Got hundreds of photos with names like IMG_4821.jpg? Python's built-in os and pathlib modules can sort them into folders by date or type automatically.
from pathlib import Path
import shutil
downloads = Path.home() / "Downloads"
for file in downloads.iterdir():
if file.suffix == ".pdf":
dest = downloads / "PDFs"
dest.mkdir(exist_ok=True)
shutil.move(str(file), str(dest / file.name))
This script scans your Downloads folder and moves every PDF into a PDFs subfolder. Extend it for any file type.
2. Sending Automated Email Reports
Python's smtplib and email modules let you send emails programmatically. Combined with schedule, you can dispatch daily reports without lifting a finger.
import smtplib
from email.mime.text import MIMEText
def send_report(to, subject, body):
msg = MIMEText(body)
msg["Subject"] = subject
msg["From"] = "you@example.com"
msg["To"] = to
with smtplib.SMTP_SSL("smtp.gmail.com", 465) as server:
server.login("you@example.com", "your_app_password")
server.send_message(msg)
Tip: Use Gmail App Passwords (not your main password) for authentication. Store credentials in environment variables, never in code.
3. Web Scraping for Price Monitoring
Track product prices across websites using requests and BeautifulSoup. Run the script daily and get alerted when a price drops.
import requests
from bs4 import BeautifulSoup
def get_price(url, selector):
headers = {"User-Agent": "Mozilla/5.0"}
res = requests.get(url, headers=headers)
soup = BeautifulSoup(res.text, "html.parser")
return soup.select_one(selector).text.strip()
Always check a website's robots.txt and terms of service before scraping. Be respectful with request rates.
4. Automating Spreadsheet Tasks
The openpyxl library lets you read, write, and manipulate Excel files without ever opening Excel. Perfect for generating monthly reports from raw data.
import openpyxl
wb = openpyxl.load_workbook("sales_data.xlsx")
ws = wb.active
total = sum(ws.cell(row=i, column=2).value or 0 for i in range(2, ws.max_row + 1))
ws.cell(row=ws.max_row + 1, column=1).value = "Total"
ws.cell(row=ws.max_row, column=2).value = total
wb.save("sales_report.xlsx")
5. Scheduling Tasks to Run Automatically
Use the schedule library to run any function at set intervals — no cron job knowledge required.
import schedule
import time
def daily_backup():
print("Running backup...")
# your backup logic here
schedule.every().day.at("02:00").do(daily_backup)
while True:
schedule.run_pending()
time.sleep(60)
Putting It All Together
| Task | Key Library | Difficulty |
|---|---|---|
| File organization | pathlib, shutil | Beginner |
| Email automation | smtplib, email | Beginner |
| Web scraping | requests, BeautifulSoup | Intermediate |
| Spreadsheet tasks | openpyxl, pandas | Intermediate |
| Task scheduling | schedule, APScheduler | Beginner |
Start with whichever task causes you the most daily friction. Even a 30-line script can save you hours per week.