Like most developers, my Downloads folder quickly turns into an unrecognizable wasteland of installers, PDFs, ZIP archives, and random screenshots. I wrote a small background daemon in Python to automatically sort files into neat subdirectories based on extension.
The Python Cleaner Script
import os
import shutil
from pathlib import Path
DOWNLOADS_DIR = Path.home() / "Downloads"
DIRECTORIES = {
"Documents": [".pdf", ".docx", ".txt", ".xlsx", ".csv"],
"Images": [".jpg", ".png", ".jpeg", ".webp", ".svg"],
"Archives": [".zip", ".tar", ".gz", ".rar", ".7z"],
"Executables": [".exe", ".msi", ".dmg"],
"Code": [".py", ".json", ".sql", ".env"]
}
def organize():
for item in DOWNLOADS_DIR.iterdir():
if item.is_file():
ext = item.suffix.lower()
for folder, extensions in DIRECTORIES.items():
if ext in extensions:
target_dir = DOWNLOADS_DIR / folder
target_dir.mkdir(exist_ok=True)
shutil.move(str(item), str(target_dir / item.name))
break
if __name__ == "__main__":
organize()
print("Downloads organized successfully!")
I set this script to run silently on system startup using Windows Task Scheduler. My desktop and downloads folder have stayed clean ever since.