An automated, intelligent, and interactive Python script designed to clean up any messy directory. It organizes loose files into smartly categorized folders and sub-folders based on their extensions, keeping your system tidy while safely handling identical filenames and hidden files.
- Nested Sub-Folders: Instead of dumping all documents into one large folder, it natively sub-categorizes your files into distinct paths like
Documents/Spreadsheets,Documents/PDFs, andDocuments/Word Documents. Media files are intuitively moved into standardPictures,Music, andVideosdirectories. - Interactive Prompts: When executed, the script asks you real-time questions in the terminal:
- Dotfiles setup: Choose to ignore
.dotfiles, group them internally, or route them to a specific external directory. - Special Pathways mapping: You can map entire categories (like
Videos) or custom individual extensions (like.logor.pdf) to completely distinct hard drives or folders anywhere on your system! If your chosen folder doesn't exist, the script can create it on the spot.
- Dotfiles setup: Choose to ignore
- Smart Duplicate Prevention: Safe by design—if a file with the same name already exists in the destination folder, the script automatically renames the new file using an incrementing counter (e.g.,
report (1).pdf,report (2).pdf) eliminating any risk of silent data wiping or overriding. - Cross-Platform Compatibility: Uses standard modern
pathlibdesign with error resistance and crash-safe UTF-8 ASCII logging natively supported on Windows Powershell, macOS, and Linux.
We included a script that safely generates a dummy directory (test_dir) filled with fake files so you can verify the organizer without risking your real files!
python generate_test_files.pyThis will create a test_dir folder. You can then run the organizer on it.
Simply run the script with Python 3 and provide the absolute or relative path to the messy folder you want to organize:
python file_organizer.py "/path/to/your/messy_folder"D:\> python file_organizer.py C:\Users\Someone\Downloads
Target directory: C:\Users\Someone\Downloads
Do you want to handle dotfiles? (Y/n): y
Do you like to move .dotfiles to a special pathway? (Y/n): n
Would you like to mention any special pathways for certain categories or extensions? (Y/n): n
Organizing...
Moved: financial_report.xlsx -> Documents/Spreadsheets/
Moved: vacation.jpg -> Pictures/
Moved: invoice.pdf -> Documents/PDFs/
[OK] Organized 3 files in C:\Users\Someone\Downloads
By default, files are sorted natively as follows (unless you choose Special Pathways):
- Documents/
PDFs/(.pdf)Text Files/(.txt, .rtf, .md)Spreadsheets/(.xls, .xlsx, .csv, .ods)Word Documents/(.doc, .docx, .odt)Presentations/(.ppt, .pptx, .odp)
- Pictures/ (.jpg, .png, .gif, .svg...)
- Videos/ (.mp4, .mkv, .avi...)
- Music/ (.mp3, .wav, .flac...)
- Archives/ (.zip, .tar, .gz, .rar...)
- Code/ (.py, .js, .html, .css...)
- Packages/ (.deb, .rpm, .appimage...)
- Dotfiles/ (hidden files starting with
.) - Others/ (unrecognized file extensions)