I'm always excited to take on new projects and collaborate with innovative minds.

Address

🇮🇹 | 🇮🇳

Social Links

5 Python Automation Scripts That Will Save You 10 Hours Every Week

A practical coding guide with 5 ready-to-use Python scripts for file organization, web scraping, email automation, PDF processing, and system monitoring.

Python automation scripts header

Every developer has repetitive tasks that eat into productive time. File organization, data extraction, email sending, PDF merging, and system checks — these are not complex problems, but they are time-consuming when done manually.

This guide gives you 5 production-ready Python scripts that you can run today. Each script solves a real problem, uses only standard libraries or common pip packages, and includes error handling so it does not break in the real world.

Whether you are a developer in Hyderabad, a freelancer in Mumbai, or a tech team in Milan or Rome, these scripts will fit into your workflow immediately.

1. Smart File Organizer — Clean Your Downloads Folder Automatically

Your Downloads folder is a mess. Everyone's is. This script sorts files by extension into categorized folders.

The Script

import os
import shutil
from pathlib import Path

DOWNLOADS = Path.home() / "Downloads"
CATEGORIES = {
    "Images": [".jpg", ".jpeg", ".png", ".gif", ".webp", ".svg"],
    "Documents": [".pdf", ".docx", ".txt", ".xlsx", ".pptx"],
    "Archives": [".zip", ".tar", ".gz", ".rar", ".7z"],
    "Code": [".py", ".js", ".html", ".css", ".json", ".yaml"],
    "Videos": [".mp4", ".mov", ".avi", ".mkv"],
}

def organize_downloads():
    for file in DOWNLOADS.iterdir():
        if file.is_file():
            ext = file.suffix.lower()
            moved = False
            for folder, extensions in CATEGORIES.items():
                if ext in extensions:
                    dest = DOWNLOADS / folder
                    dest.mkdir(exist_ok=True)
                    shutil.move(str(file), str(dest / file.name))
                    moved = True
                    break
            if not moved:
                other = DOWNLOADS / "Others"
                other.mkdir(exist_ok=True)
                shutil.move(str(file), str(other / file.name))
    print("Downloads organized successfully.")

if __name__ == "__main__":
    organize_downloads()

How to Run Daily

Add this to your crontab (Linux/Mac) or Task Scheduler (Windows) to run every morning at 9 AM. Your downloads folder will never be chaotic again.

2. Web Scraping with Error Recovery — Extract Data Without Breaking

Scraping fails. Websites change. Networks timeout. This script handles all of that gracefully.

The Script

import requests
from bs4 import BeautifulSoup
import time
import json

def scrape_with_retry(url, retries=3, delay=2):
    headers = {
        "User-Agent": "Mozilla/5.0 (compatible; Bot/1.0)"
    }
    for attempt in range(retries):
        try:
            response = requests.get(url, headers=headers, timeout=10)
            response.raise_for_status()
            return response.text
        except requests.RequestException as e:
            print(f"Attempt {attempt + 1} failed: {e}")
            if attempt < retries - 1:
                time.sleep(delay * (attempt + 1))
    return None

def extract_article_links(html, base_url):
    soup = BeautifulSoup(html, "html.parser")
    links = []
    for a in soup.find_all("a", href=True):
        href = a["href"]
        if href.startswith("/"):
            href = base_url + href
        if base_url in href:
            links.append({"title": a.get_text(strip=True), "url": href})
    return links

if __name__ == "__main__":
    url = "https://example-blog.com"
    html = scrape_with_retry(url)
    if html:
        articles = extract_article_links(html, url)
        with open("articles.json", "w", encoding="utf-8") as f:
            json.dump(articles, f, indent=2, ensure_ascii=False)
        print(f"Saved {len(articles)} articles to articles.json")
    else:
        print("Failed to fetch page after retries.")

Why This Works

The exponential backoff (delay * (attempt + 1)) prevents hammering the server. The custom User-Agent reduces blocks. JSON output with ensure_ascii=False handles Indian and Italian text correctly.

3. Bulk Email Sender with Personalization — Reach Clients Without Manual Work

Whether you are sending cold outreach to European businesses or newsletters to Indian clients, personalized emails get better response rates.

The Script

import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
import csv
import time

SMTP_SERVER = "smtp.gmail.com"
SMTP_PORT = 465
SENDER_EMAIL = "your-email@gmail.com"
APP_PASSWORD = "your-app-password"

def send_email(to_email, name, company, subject, template):
    msg = MIMEMultipart()
    msg["From"] = SENDER_EMAIL
    msg["To"] = to_email
    msg["Subject"] = subject

    body = template.replace("{name}", name).replace("{company}", company)
    msg.attach(MIMEText(body, "plain", "utf-8"))

    try:
        with smtplib.SMTP_SSL(SMTP_SERVER, SMTP_PORT) as server:
            server.login(SENDER_EMAIL, APP_PASSWORD)
            server.send_message(msg)
        print(f"Sent to {to_email}")
        return True
    except Exception as e:
        print(f"Failed to send to {to_email}: {e}")
        return False

def bulk_send(csv_file, subject, template, delay=5):
    with open(csv_file, "r", encoding="utf-8") as f:
        reader = csv.DictReader(f)
        for row in reader:
            success = send_email(row["email"], row["name"], row["company"], subject, template)
            if success:
                time.sleep(delay)

if __name__ == "__main__":
    template = "Hi {name},\n\nI noticed {company} is growing fast. I help tech teams automate repetitive tasks with Python. Would you be open to a 10-minute chat?\n\nBest regards"
    bulk_send("contacts.csv", "Quick question about {company}", template)

CSV Format

email,name,company
info@gasthaus-koeln.de,Manager,Gasthaus Koln
contact@hotel-de-lyon.fr,Director,Hotel de Lyon

Important Note

Gmail has rate limits. Send no more than 100 emails per day. Add a 5-second delay between sends. For larger campaigns, use a service like SendGrid or AWS SES.

4. PDF Merger and Splitter — Handle Documents Programmatically

Developers and businesses in India and Italy both deal with PDFs daily — invoices, contracts, reports. This script merges multiple PDFs and splits large ones.

The Script

from PyPDF2 import PdfMerger, PdfReader, PdfWriter
from pathlib import Path

def merge_pdfs(input_files, output_file):
    merger = PdfMerger()
    for pdf in input_files:
        merger.append(pdf)
    merger.write(output_file)
    merger.close()
    print(f"Merged into {output_file}")

def split_pdf(input_file, output_prefix, pages_per_split=10):
    reader = PdfReader(input_file)
    total_pages = len(reader.pages)
    for start in range(0, total_pages, pages_per_split):
        writer = PdfWriter()
        end = min(start + pages_per_split, total_pages)
        for i in range(start, end):
            writer.add_page(reader.pages[i])
        output_path = f"{output_prefix}_part{start//pages_per_split + 1}.pdf"
        with open(output_path, "wb") as f:
            writer.write(f)
        print(f"Saved {output_path} ({start+1}-{end})")

if __name__ == "__main__":
    # Example: merge all PDFs in a folder
    pdfs = sorted(Path(".").glob("*.pdf"))
    if pdfs:
        merge_pdfs(pdfs, "merged_document.pdf")

Installation

pip install PyPDF2

This is lightweight and works on any machine — no Adobe license needed.

5. System Health Monitor — Watch Your Server Like a Hawk

If you run VPS servers on Hostinger, AWS, DigitalOcean, or any Italian hosting provider, you need to know when disk space or memory runs low before your site crashes.

The Script

import psutil
import datetime
import json

def check_system_health():
    cpu = psutil.cpu_percent(interval=1)
    memory = psutil.virtual_memory()
    disk = psutil.disk_usage("/")
    boot_time = datetime.datetime.fromtimestamp(psutil.boot_time())

    health = {
        "timestamp": datetime.datetime.now().isoformat(),
        "cpu_percent": cpu,
        "memory_percent": memory.percent,
        "memory_available_gb": round(memory.available / (1024**3), 2),
        "disk_percent": disk.percent,
        "disk_free_gb": round(disk.free / (1024**3), 2),
        "uptime_hours": round((datetime.datetime.now() - boot_time).total_seconds() / 3600, 2),
    }

    # Alert thresholds
    alerts = []
    if cpu > 80:
        alerts.append(f"CPU usage is {cpu}%")
    if memory.percent > 85:
        alerts.append(f"Memory usage is {memory.percent}%")
    if disk.percent > 90:
        alerts.append(f"Disk usage is {disk.percent}%")

    if alerts:
        print("ALERTS:")
        for alert in alerts:
            print(f"  - {alert}")
    else:
        print("System healthy.")

    with open("health_log.json", "a", encoding="utf-8") as f:
        f.write(json.dumps(health) + "\n")

    return health

if __name__ == "__main__":
    check_system_health()

Installation

pip install psutil

Run as a Cron Job

*/30 * * * * /usr/bin/python3 /path/to/health_monitor.py

This runs every 30 minutes and logs system stats. Pair it with a Telegram bot or email alert for critical thresholds, and you have a free server monitoring solution.

How to Turn These Scripts Into an AI Agent

Each script above is a standalone tool. If you wrap them in a single orchestrator that decides which script to run based on user input, you have built an AI agent. Here is the pattern:

1. Intent Detection: Use a simple keyword match or a lightweight LLM to understand what the user wants.

2. Tool Router: Map intents to script functions.

3. Execution: Run the script with user-provided parameters.

4. Response: Return the result in natural language.

This is exactly how tarun.ai operates — a collection of specialized scripts orchestrated by a decision engine. You do not need a massive framework. You need good scripts and a simple router.

Key Takeaways

- File organization, web scraping, email sending, PDF handling, and system monitoring are the 5 most common automation needs for developers and small businesses.

- Python's standard library plus a few pip packages (requests, beautifulsoup4, PyPDF2, psutil) covers all of them.

- Error handling and retry logic are not optional — they separate scripts that work once from scripts that run reliably.

- These scripts work on any machine: a MacBook in Bangalore, a Windows laptop in Delhi, or a VPS in Frankfurt.

- The next step is wrapping them in an agent framework so they run autonomously based on triggers.

Conclusion

Automation is not about replacing developers. It is about removing the repetitive 80 percent of work so you can focus on the creative 20 percent. These 5 scripts are a starting point. Customize them for your workflow, schedule them with cron or Windows Task Scheduler, and reclaim your time.

If you are building an AI agent or automation pipeline, these scripts are your foundation blocks. Start with one. Run it today. See the time you save. Then add the next.

Tharun Ramagiri is a web developer, security researcher, and AI enthusiast based in India. He builds autonomous AI agents that handle content creation, security auditing, and business automation. He writes about Python, AI, and practical development workflows for Indian and European tech audiences.

python, automation, coding, productivity, web development, AI agents, tutorial
8 min read
May 22, 2026
By Tharun Ramagiri
Share

Leave a comment

Your email address will not be published. Required fields are marked *