Tutorial
How to Automate Your Daily Tasks Using Python Scripts
Learn to save hours each week by automating file organization, web scraping, email reports, data cleaning, and system cleanup with simple Python scripts — no programming expertise required.
June 2026 · 12 min read · 1 views · 0 hearts
Advertisement
How to Automate Your Daily Tasks Using Python Scripts
You probably spend more time clicking through folders, renaming files, and fixing spreadsheet columns than you realize. Python can take those unrewarding, repetitive minutes and turn them into seconds — freeing you to do the work that actually matters.
Why Python Is the Best Tool for Automation
Python is everywhere for a reason. It's readable, it's flexible, and it has a massive library ecosystem. Whether you need to manipulate files, scrape websites, send emails, or process data, there's almost certainly a library that's already been battle-tested. And you don't need to be a programmer to write scripts that save you an hour each day.
Prerequisites: What You'll Need
Before diving in, make sure you have Python installed and know how to install packages with pip. If you haven't done this yet, head to python.org, download the latest version, and verify with python --version in your terminal.
Five Automations That Will Change Your Workflow
1. Bulk File Renaming and Organization
Dragging files from your Downloads folder into neatly organized directories is tedious and error-prone. Here's a script that moves all PDFs from a folder into a subfolder, renames them with today's date, and logs what it did.
import os
import shutil
from datetime import datetime
source_folder = "/path/to/downloads"
pdf_folder = os.path.join(source_folder, "PDFs")
if not os.path.exists(pdf_folder):
os.makedirs(pdf_folder)
today = datetime.now().strftime("%Y-%m-%d")
for filename in os.listdir(source_folder):
if filename.endswith(".pdf"):
new_name = f"{today}_{filename}"
src = os.path.join(source_folder, filename)
dst = os.path.join(pdf_folder, new_name)
shutil.move(src, dst)
print(f"Moved: {filename} -> {new_name}")
You can adapt this for images, spreadsheets, or any file type you regularly download. Run it once a day, or schedule it with cron (Linux/macOS) or Task Scheduler (Windows).
2. Web Scraping for Price Drops and Alerts
Instead of refreshing a product page every few hours, let Python do the watching. This example uses requests and BeautifulSoup to check the price of an item and send an email if it drops below your target.
import requests
from bs4 import BeautifulSoup
import smtplib
from email.message import EmailMessage
def check_price(url, target_price):
headers = {"User-Agent": "Mozilla/5.0"}
response = requests.get(url, headers=headers)
soup = BeautifulSoup(response.text, "html.parser")
# Adjust the selector based on the actual site structure
price_element = soup.find("span", class_="price")
if price_element:
price = float(price_element.text.replace("$", ""))
if price <= target_price:
msg = EmailMessage()
msg.set_content(f"Price dropped to ${price} at {url}")
msg["Subject"] = "Price Alert"
msg["From"] = "you@gmail.com"
msg["To"] = "you@gmail.com"
with smtplib.SMTP_SSL("smtp.gmail.com", 465) as server:
server.login("you@gmail.com", "your_password")
server.send_message(msg)
check_price("https://example.com/product", 100.0)
Note: Be respectful to websites — don't scrape too aggressively, and check their robots.txt first.
3. Automated Email Reports with Attachments
Do you send a weekly status report to the same group? Let Python handle the template, attach the latest CSV, and fire it off on schedule.
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.base import MIMEBase
from email import encoders
def send_report(recipient, subject, body, file_path):
msg = MIMEMultipart()
msg["From"] = "you@company.com"
msg["To"] = recipient
msg["Subject"] = subject
msg.attach(MIMEText(body, "plain"))
with open(file_path, "rb") as attachment:
part = MIMEBase("application", "octet-stream")
part.set_payload(attachment.read())
encoders.encode_base64(part)
part.add_header("Content-Disposition", f"attachment; filename={file_path}")
msg.attach(part)
with smtplib.SMTP("smtp.yourcompany.com", 587) as server:
server.starttls()
server.login("you@company.com", "password")
server.send_message(msg)
You can combine this with data processing scripts that generate the report before sending — a perfect Monday morning routine.
4. Data Cleaning and Transformation
If your job involves Excel spreadsheets or CSVs, you know the pain of removing duplicates, fixing date formats, or merging columns. The pandas library makes this trivial.
import pandas as pd
df = pd.read_csv("messy_data.csv")
df.drop_duplicates(subset=["email"], inplace=True)
df["date"] = pd.to_datetime(df["date"], errors="coerce")
df.fillna({"status": "unknown"}, inplace=True)
df.to_csv("cleaned_data.csv", index=False)
print("Data cleaned and saved.")
This script alone can replace 30 minutes of manual clicking in Excel.
5. System Cleanup: Removing Old Temp Files
Temporary files pile up fast. Python can scan your system's temp directories, delete files older than 30 days, and even log what it removed.
import os
import time
import shutil
days_old = 30
temp_dir = "/tmp"
now = time.time()
for item in os.listdir(temp_dir):
item_path = os.path.join(temp_dir, item)
if os.stat(item_path).st_mtime < now - (days_old * 86400):
try:
if os.path.isfile(item_path):
os.remove(item_path)
else:
shutil.rmtree(item_path)
print(f"Removed: {item_path}")
except Exception as e:
print(f"Error removing {item_path}: {e}")
Safety first: Always test this script on a test directory before pointing it at system locations.
Scheduling Your Scripts to Run Automatically
Writing the script is only half the work. You need it to run without you remembering to do it.
- Windows: Use Task Scheduler. Create a task that runs
python C:\path\to\script.pyat your chosen time. - macOS/Linux: Use cron. Run
crontab -eand add a line like0 9 * * 1 /usr/bin/python3 /home/you/scripts/report.pyto run every Monday at 9 AM.
Common Pitfalls and How to Avoid Them
- Hardcoded paths: Use
os.path.join()and relative paths when possible, so your script works on any machine. - No error handling: Wrap risky operations in
try/exceptblocks so your script doesn't crash halfway through. - Running with full permissions unnecessarily: Don't run your scripts as admin or root unless they absolutely need it — one wrong line can delete important files.
- Not logging: Add
print()statements or write to a log file. When something goes wrong, you'll thank yourself.
What's Next?
Start small. Pick one task that irritates you daily — a file you always rename, a report you manually generate — and build a script for it. Once you see how much time it saves, you'll find yourself looking for more tasks to automate.
Python scripting is less about being a genius programmer and more about being lazy in the smart way. And that's a skill worth developing.
Advertisement
Comments
Questions, corrections, and tips stay visible for everyone reading this page.
Join the discussion
No comments yet
Be the first to leave a note — it helps the next reader.