Stop Doing Manually What Python Can Do in Seconds
I automate everything I can. Here are 10 scripts that changed my workflow forever.
1. File Organizer
import os
import shutil
from pathlib import Path
CATEGORIES = {
'Images': ['.jpg', '.png', '.gif', '.svg', '.webp'],
'Documents': ['.pdf', '.doc', '.docx', '.txt', '.md'],
'Code': ['.py', '.js', '.ts', '.swift', '.html', '.css'],
'Data': ['.csv', '.json', '.xml', '.xlsx'],
'Archives': ['.zip', '.tar', '.gz', '.rar']
}
def organize(directory):
for file in Path(directory).iterdir():
if file.is_file():
for category, extensions in CATEGORIES.items():
if file.suffix.lower() in extensions:
dest = Path(directory) / category
dest.mkdir(exist_ok=True)
shutil.move(str(file), str(dest / file.name))
break
organize('~/Downloads')
2. Bulk Image Resizer
from PIL import Image
from pathlib import Path
def resize_images(folder, max_size=(1200, 1200)):
for img_path in Path(folder).glob('*.{jpg,png}'):
img = Image.open(img_path)
img.thumbnail(max_size, Image.LANCZOS)
img.save(img_path)
print(f"Resized: {img_path.name}")
3. CSV to JSON Converter
import csv
import json
def csv_to_json(csv_file, json_file):
with open(csv_file, 'r') as f:
reader = csv.DictReader(f)
data = list(reader)
with open(json_file, 'w') as f:
json.dump(data, f, indent=2)
4. Website Availability Checker
import requests
import time
SITES = ['https://yoursite.com', 'https://api.yoursite.com']
def check_sites():
for site in SITES:
try:
r = requests.get(site, timeout=10)
status = "UP" if r.status_code == 200 else f"DOWN ({r.status_code})"
except:
status = "UNREACHABLE"
print(f"{site}: {status}")
# Run every 5 minutes with cron
check_sites()
5. Git Stats Generator
import subprocess
def git_stats():
commits = subprocess.run(['git', 'log', '--oneline'], capture_output=True, text=True)
total = len(commits.stdout.strip().split('\n'))
authors = subprocess.run(['git', 'shortlog', '-sn'], capture_output=True, text=True)
print(f"Total commits: {total}")
print(f"\nContributors:\n{authors.stdout}")
git_stats()
6-10: Quick Wins
- Email report sender — auto-generate and send daily reports
- Database backup — scheduled SQLite/PostgreSQL dumps
- Log analyzer — parse logs and alert on errors
- API data fetcher — pull data from APIs on schedule
- Markdown to PDF — convert docs with custom styling
The Key Principle
If you do something more than twice, automate it. The 30 minutes you spend writing a script saves hours over its lifetime.
Getting Started
- Pick your most repetitive task
- Write a Python script for it
- Schedule it with cron (Linux/Mac) or Task Scheduler (Windows)
- Forget about it forever
Which tasks do you automate? Share in the comments!
Follow me: @SwiftUIDaily on Telegram
Top comments (0)