Advertisement

Why Automate?

As a student juggling schoolwork, freelance projects, and personal development, I quickly realised that anything I do more than three times should be automated. Python makes this incredibly easy its standard library alone covers file management, HTTP requests, email, and scheduling.

The philosophy is simple: if a computer can do it, a computer should do it. Your time is better spent on creative problem-solving, not repetitive clicking.

File Organisation Script

One of the first scripts I wrote was a file organiser for my Downloads folder. It watches for new files and sorts them into folders by extension:

import os
import shutil
from pathlib import Path

downloads = Path.home() / "Downloads"
folders = {
    "Images": [".jpg", ".png", ".gif", ".svg", ".webp"],
    "Documents": [".pdf", ".docx", ".xlsx", ".pptx"],
    "Code": [".py", ".js", ".html", ".css", ".json"],
    "Videos": [".mp4", ".mov", ".avi"],
}

for file in downloads.iterdir():
    if file.is_file():
        for folder, extensions in folders.items():
            if file.suffix.lower() in extensions:
                dest = downloads / folder
                dest.mkdir(exist_ok=True)
                shutil.move(str(file), str(dest / file.name))
                print(f"Moved {file.name} ' {folder}/")
                break

I run this as a scheduled task every hour. My Downloads folder has never been cleaner.

Web Scraping for Data Collection

For my crypto analytics dashboard, I needed regular price data. Instead of manually downloading CSVs, I wrote a scraper using requests and BeautifulSoup:

import requests
from bs4 import BeautifulSoup
import pandas as pd
from datetime import datetime

def scrape_crypto_prices():
    url = "https://example-crypto-api.com/prices"
    response = requests.get(url, timeout=10)
    soup = BeautifulSoup(response.text, "html.parser")
    
    data = []
    for row in soup.select(".price-row"):
        data.append({
            "coin": row.select_one(".coin-name").text.strip(),
            "price": float(row.select_one(".price").text.replace("$", "").replace(",", "")),
            "timestamp": datetime.now().isoformat()
        })
    
    df = pd.DataFrame(data)
    df.to_csv("crypto_data.csv", mode="a", header=False, index=False)
    print(f"Scraped {len(data)} prices at {datetime.now()}")

scrape_crypto_prices()
Advertisement

Automated Email Reports

Another useful automation: sending myself a weekly summary email with project stats. Python's smtplib handles this elegantly:

import smtplib
from email.mime.text import MIMEText

def send_weekly_report(stats):
    msg = MIMEText(f"""
    Weekly Developer Report:
    - Commits this week: {stats['commits']}
    - Lines written: {stats['lines']}
    - Active projects: {stats['projects']}
    """)
    msg["Subject"] = "Weekly Dev Report"
    msg["From"] = "bot@example.com"
    msg["To"] = "connect.adityasahani@gmail.com"
    
    with smtplib.SMTP_SSL("smtp.gmail.com", 465) as server:
        server.login("bot@example.com", "app_password")
        server.send_message(msg)

Scheduling with Cron and Task Scheduler

On Linux/Mac, I use cron jobs. On Windows, Task Scheduler does the same thing. The key insight: automation scripts should be idempotent running them twice should produce the same result as running them once. This prevents data duplication and makes debugging much easier.

My Automation Stack

Here's what I use daily:

Start Small, Then Scale

My advice for anyone starting with Python automation: begin with something you genuinely do repeatedly. Don't try to automate everything at once. Pick the most annoying manual task in your workflow, write a script for it, and let that momentum carry you to the next one.

Once you experience the satisfaction of watching a script do in 3 seconds what used to take you 10 minutes, you'll never go back.

Need a Custom Automation Script?

I build Python automation tools for businesses and individuals.

Get in Touch '
Advertisement