Automating Daily Tasks with Python: Scripts That Save You Hours

Ever feel like you’re stuck in a loop of repetitive chores while the world races ahead with new gadgets and AI breakthroughs? That nagging feeling that you could be building something cool instead of manually moving files or sifting through endless emails is exactly why I dove into Python automation last year. The payoff? Hours reclaimed, mental bandwidth freed, and a tiny sense of wizardry every time a script runs on its own.

Why Automation Matters

Automation isn’t just a buzzword for tech giants; it’s a practical tool for anyone who wants to spend less time on the mundane and more time on the meaningful. Think of it as the digital equivalent of setting your coffee maker to brew before you roll out of bed. The tasks we automate today become invisible background processes tomorrow, letting us focus on creativity, learning, or simply enjoying a quiet moment without the ping of a new notification.

From a broader perspective, automating routine work also reduces human error. A script will sort a file the same way every time, whereas a tired brain might miss a stray PDF or mis‑label a spreadsheet. The result is cleaner data, smoother workflows, and—yes—more confidence that the little things are being handled correctly.

Getting Started: The Minimal Setup

Before you start writing code that runs your life, let’s make sure the foundation is solid. You only need three things:

  1. Python installed – The latest stable version (3.10 or newer) works fine. Download it from python.org and tick the “Add to PATH” box during installation.
  2. A code editor – VS Code, Sublime Text, or even the built‑in IDLE will do. I personally love VS Code because of its extensions and built‑in terminal.
  3. A handful of libraries – Most automation tasks rely on os (for interacting with the operating system), shutil (for moving files), smtplib (for sending email), and pandas (for handling tabular data). Install them with pip, Python’s package manager, like so:
pip install pandas

That’s it. With these tools, you can start building scripts that run on a schedule, on demand, or even trigger from a simple voice command if you’re feeling adventurous.

Three Everyday Scripts You Can Deploy Today

Below are three practical scripts that I use daily. They’re deliberately simple, so you can copy, tweak, and run them without diving deep into advanced Python concepts.

1. Email Triage Bot

The problem: Your inbox is a battlefield. Important messages get lost among newsletters, receipts, and spam.

The solution: A script that logs into your Gmail (or any IMAP‑compatible service), scans for unread messages, and forwards only those that match certain keywords to a “Priority” label.

import imaplib
import email
import smtplib

IMAP_SERVER = 'imap.gmail.com'
SMTP_SERVER = 'smtp.gmail.com'
USERNAME = '[email protected]'
PASSWORD = 'your_app_password'   # Use an app‑specific password for security

def fetch_unread():
    mail = imaplib.IMAP4_SSL(IMAP_SERVER)
    mail.login(USERNAME, PASSWORD)
    mail.select('inbox')
    typ, data = mail.search(None, 'UNSEEN')
    return data[0].split()

def forward_message(msg_id):
    # Fetch the raw email
    typ, msg_data = mail.fetch(msg_id, '(RFC822)')
    raw_email = msg_data[0][1]
    msg = email.message_from_bytes(raw_email)

    # Simple keyword filter
    keywords = ['invoice', 'meeting', 'deadline']
    if any(k in msg['subject'].lower() for k in keywords):
        # Forward via SMTP
        with smtplib.SMTP_SSL(SMTP_SERVER) as server:
            server.login(USERNAME, PASSWORD)
            forward = f"Subject: FWD: {msg['subject']}\n\n{msg.get_payload(decode=True).decode()}"
            server.sendmail(USERNAME, USERNAME, forward)

for uid in fetch_unread():
    forward_message(uid)

Why it works: The script runs in under a minute, pulls only unread messages, checks the subject line for your chosen keywords, and forwards the relevant ones back to your own inbox under a distinct label. Set it as a daily cron job (or Windows Task Scheduler) and watch the clutter shrink.

2. File Organizer

The problem: Downloads folder becomes a black hole of PDFs, images, installers, and random zip files.

The solution: A folder‑watcher that moves files into categorized subfolders based on extension and, for documents, creation date.

import os
import shutil
from datetime import datetime

DOWNLOADS = os.path.expanduser('~/Downloads')
TARGETS = {
    '.pdf': 'Documents',
    '.docx': 'Documents',
    '.xlsx': 'Spreadsheets',
    '.png': 'Images',
    '.jpg': 'Images',
    '.zip': 'Archives',
    '.exe': 'Installers'
}

def organize():
    for item in os.listdir(DOWNLOADS):
        src = os.path.join(DOWNLOADS, item)
        if os.path.isfile(src):
            ext = os.path.splitext(item)[1].lower()
            folder = TARGETS.get(ext, 'Misc')
            # Create subfolder for the month if it's a document
            if folder == 'Documents':
                date = datetime.fromtimestamp(os.path.getctime(src))
                folder = os.path.join(folder, date.strftime('%Y-%m'))
            dest_dir = os.path.join(DOWNLOADS, folder)
            os.makedirs(dest_dir, exist_ok=True)
            shutil.move(src, os.path.join(dest_dir, item))

organize()

Why it works: By running this script once a day, your Downloads folder stays tidy without you having to think about it. The month‑based subfolders for documents make it easy to locate that report you wrote in March.

3. Daily Report Generator

The problem: At the end of each workday you need to send a quick summary of tasks completed, time spent, and any blockers.

The solution: A script that reads a simple CSV log you update throughout the day and emails a formatted summary to yourself (or your manager).

import pandas as pd
import smtplib
from email.mime.text import MIMEText

LOG_FILE = 'task_log.csv'   # Columns: date, task, hours, notes
SMTP_SERVER = 'smtp.gmail.com'
USERNAME = '[email protected]'
PASSWORD = 'your_app_password'

def send_report():
    df = pd.read_csv(LOG_FILE)
    today = pd.Timestamp('today').normalize()
    today_tasks = df[df['date'] == today.strftime('%Y-%m-%d')]

    if today_tasks.empty:
        return

    total_hours = today_tasks['hours'].sum()
    body = f"Daily Report for {today.strftime('%b %d, %Y')}\n\n"
    for _, row in today_tasks.iterrows():
        body += f"- {row['task']} ({row['hours']}h): {row['notes']}\n"
    body += f"\nTotal Hours: {total_hours:.2f}"

    msg = MIMEText(body)
    msg['Subject'] = f'Daily Report – {today.strftime('%b %d')}"
    msg['From'] = USERNAME
    msg['To'] = USERNAME

    with smtplib.SMTP_SSL(SMTP_SERVER) as server:
        server.login(USERNAME, PASSWORD)
        server.send_message(msg)

send_report()

Why it works: The CSV acts as a lightweight “logbook” you can edit in any spreadsheet app. At 6 pm, the script compiles the rows for that day, totals the hours, and shoots an email to your inbox. No more scrambling to remember what you did at 4 pm.

Tips for Keeping Your Scripts Friendly

  1. Error handling matters – Wrap file operations in try/except blocks. A missing file shouldn’t crash your entire automation pipeline.
  2. Log, don’t print – Use Python’s built‑in logging module to record what happened each run. It’s far easier to debug later.
  3. Secure your credentials – Store passwords in environment variables or use a secrets manager. Hard‑coding them is a recipe for a security nightmare.
  4. Modularize – Break each script into functions that do one thing well. This makes future tweaks (like adding a new file type) painless.
  5. Schedule wisely – Running a script every minute can be overkill. Align the frequency with the task’s natural rhythm; daily for reports, hourly for inbox checks, weekly for deep clean‑ups.

Automation is a mindset as much as a set of tools. Once you get the habit of asking, “Can I write a tiny program to do this?” you’ll find yourself solving problems before they even surface. The scripts above are just the tip of the iceberg—feel free to remix them, add your own flair, and watch your daily grind shrink.

Reactions