DEV Community

Jeffrey.Feillp
Jeffrey.Feillp

Posted on

Python Automation: 5 Scripts That Save Me 20 Hours Every Week

Python Automation: 5 Scripts That Save Me 20 Hours Every Week

I'm lazy. So I automate everything. Here are 5 Python scripts that save me 20+ hours every week.

1. File Organizer

import os, shutil
from pathlib import Path

extensions = {{
    '.jpg': 'Images', '.png': 'Images',
    '.mp4': 'Videos', '.mov': 'Videos',
    '.pdf': 'Documents', '.docx': 'Documents',
    '.zip': 'Archives', '.rar': 'Archives',
}}

def organize(downloads):
    for f in Path(downloads).iterdir():
        if f.is_file():
            folder = extensions.get(f.suffix.lower(), 'Other')
            f.rename(Path(downloads) / folder / f.name)
Enter fullscreen mode Exit fullscreen mode

2. Automated CSV Report Generator

import pandas as pd

def generate_report(data_file):
    df = pd.read_csv(data_file)
    summary = df.groupby('category').agg({{
        'revenue': 'sum', 'orders': 'count'
    }})
    summary.to_excel('report.xlsx')
Enter fullscreen mode Exit fullscreen mode

3. Bulk Image Resizer

from PIL import Image
import os

def resize_images(folder, max_width=1920):
    for f in os.listdir(folder):
        if f.lower().endswith(('.png', '.jpg', '.jpeg')):
            img = Image.open(os.path.join(folder, f))
            ratio = max_width / img.width
            if ratio < 1:
                img = img.resize((max_width, int(img.height * ratio)))
                img.save(os.path.join(folder, f))
Enter fullscreen mode Exit fullscreen mode

4. Social Media Post Scheduler

import requests, json

def schedule_post(platform, content, time):
    webhook_urls = {{
        'telegram': 'https://api.telegram.org/...',
        'discord': 'https://discord.com/api/webhooks/...',
    }}
    # Schedule via cron-compatible approach
    with open('schedule.json', 'a') as f:
        json.dump({{'time': time, 'platform': platform, 'content': content}}, f)
Enter fullscreen mode Exit fullscreen mode

5. Automated Email Responder

import imaplib, smtplib
from email.message import EmailMessage

def auto_reply(email_user, email_pass):
    mail = imaplib.IMAP4_SSL('imap.gmail.com')
    mail.login(email_user, email_pass)
    mail.select('inbox')
    # Process unread emails and auto-reply based on keywords
Enter fullscreen mode Exit fullscreen mode

Full Automation Toolkit

All 5 scripts + 15 more, packaged as a complete automation toolkit:

πŸ‘‰ Get the Python Automation Toolkit β€” $15 USDT (TRC-20)

USDT TRC-20: TNeUMpbwWFcv6v7tYHmkFkE7gC5eWzqbrs


Published str(int(time.time()))

Top comments (0)