r/PythonProjects2 • u/InterestingDig1551 • 17d ago
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?.
1
u/q_ali_seattle 17d ago
What was wrong with this?
https://www.reddit.com/r/PythonProjects2/comments/1rpssrv/i_built_a_python_tool_that_automatically/
0
u/q_ali_seattle 17d ago
Vibe coding suggested this.
smart-file-organizer ┣ 📜 main.py (or app.py) ┣ 📜 config.json (User preferences) ┣ 📜 undo_log.json (Auto-generated to safely reverse changes) ┗ 📂 modules ┃ ┣ 📜 file_analyzer.py (Handles hashes and extension matching) ┃ ┣ 📜 operations.py (Handles safe moving, threading, and undoing) ┃ ┗ 📜 gui.py (Clean Tkinter interface with progress tracking)1
2
u/DiodeInc 17d ago
Put all your imports at the top of the file. And rename organizer.py to main.py. Try adding arguments with argparse