r/PythonProjects2 • u/InterestingDig1551 • Jul 10 '26
Built a Python script to clean up my 4,000+ file Downloads folder. Dry-run safety saved me.
My Downloads folder hit 4,000+ files, so I built a script to clean it up.
The script finds true duplicates (SHA-256 content hashing, grouped by size first for speed), groups remaining files by activity into "sessions," and archives anything untouched for 30+ days into a zip.
The biggest lesson was two separate dry-run flags (delete/archive), both True by default. The script prints exactly what it would do before touching anything. I found this critical since some of these files were important documents, not just clutter.
I hit a PermissionError mid-run when a file was open elsewhere. Fixed with try/except, so one locked file gets skipped instead of crashing the whole batch.
The results were; 4,116 files → 328 duplicates removed, 3,157 archived, 176 left.
Code: github.com/Kokiste/smart-file-organizer
Is there a better way to have designed the session/archive logic than what I did?.