Menu

1 / 2

5 Python Scripts That Eliminated My Most Hated Business Tasks

DEV Community·Brad·6 months ago
#ZEBXALB1
Reading 0:00
15s threshold

Every Sunday I used to spend 2 hours on business admin. Now Python handles it automatically.

Here are 5 scripts that made the biggest difference:

1. File Organizer (Runs Daily via Cron)

import shutil from pathlib import Path from datetime import datetime

RULES = { " invoices " : [ " .pdf " ], " images " : [ " .jpg " , " .jpeg " , " .png " ], " documents " : [ " .doc " , " .docx " , " .txt " ], " data " : [ " .csv " , " .xlsx " ] }

def organize ( source , target ): moved = 0 for file in Path ( source ). iterdir (): if not file . is_file (): continue for folder , exts in RULES . items (): if file . suffix . lower () in exts : dest = Path ( target ) / folder dest . mkdir ( exist_ok = True ) final = dest / file . name if final . exists (): ts = datetime . now (). strftime ( " %Y%m%d_%H%M%S " ) final = dest / ( file . stem + " _ " + ts + file . suffix ) shutil .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.