DEV Community

Xinglin Ming
Xinglin Ming

Posted on

How I Automated 80% of My Daily Work With Python (Tutorial)

How I Automated 80% of My Daily Work With Python

A step-by-step guide to the automation scripts I use every day.

Morning: Email & File Organization

Every morning, my automation script:

  1. Downloads email attachments
  2. Sorts files into folders
  3. Generates a daily summary
import os, shutil
from pathlib import Path

def morning_routine(downloads_path):
    """Organize downloads folder automatically"""
    folders = {
        "PDFs": [".pdf"],
        "Images": [".jpg", ".png", ".gif"],
        "Documents": [".docx", ".xlsx", ".pptx"],
        "Data": [".csv", ".json", ".xml"],
    }

    path = Path(downloads_path)
    for folder, exts in folders.items():
        target = path / folder
        target.mkdir(exist_ok=True)
        for ext in exts:
            for f in path.glob(f"*{ext}"):
                if f.is_file():
                    shutil.move(str(f), str(target / f.name))
                    print(f"Moved {f.name} -> {folder}/")

morning_routine("C:/Users/YourName/Downloads")
Enter fullscreen mode Exit fullscreen mode

Midday: Data Processing

I process incoming data automatically:

import pandas as pd

def process_data(filepath):
    # Auto-detect and load
    df = pd.read_csv(filepath) if filepath.endswith(".csv") else pd.read_excel(filepath)
    # Clean
    df = df.drop_duplicates().fillna(0)
    # Analyze
    report = {
        "rows": len(df),
        "columns": list(df.columns),
        "total_value": df.iloc[:, -1].sum() if len(df.columns) > 0 else 0
    }
    return report
Enter fullscreen mode Exit fullscreen mode

Evening: Report Generation

My end-of-day script aggregates everything into a report and sends it via email.


Get The Complete Automation Toolkit

These scripts and 30+ more are available in my professionally packaged tools:

Follow for daily Python automation tutorials!

Top comments (0)