Automatically sorts cluttered folders into clean, categorized directories — in one script run.
Most people's Downloads folder is a disaster. This script fixes that automatically.
Run it once — it scans the target folder, creates category subfolders if they don't exist, and moves every file into the right place based on its extension.
Before:
Downloads/
├── resume.pdf
├── holiday.mp4
├── screenshot.png
├── notes.docx
├── random_file.xyz
├── lecture.mp4
└── budget.xlsx
After:
Downloads/
├── Documents/
│ ├── resume.pdf
│ ├── notes.docx
│ └── budget.xlsx
├── Videos/
│ ├── holiday.mp4
│ └── lecture.mp4
├── Photos/
│ └── screenshot.png
└── Others/
└── random_file.xyz
- Auto-creates folders —
Documents,Videos,Photos,Othersare created only if they don't already exist - Smart sorting — files are moved based on their extension automatically
- Catch-all — anything that doesn't match a known category goes to
Others, nothing gets lost - Non-destructive — only moves files, never deletes anything
- Zero dependencies — uses only Python's built-in
osandshutilmodules, no pip install needed
| Folder | Extensions |
|---|---|
| 📄 Documents | .pdf .docx .doc .txt .xlsx .xls .pptx .csv |
| 🎬 Videos | .mp4 .mkv .avi .mov .wmv .flv |
| 🖼️ Photos | .jpg .jpeg .png .gif .bmp .svg .webp |
| 📦 Others | Anything not in the above categories |
1. Clone the repo
git clone https://github.com/AshirNarang/file-organizer-python.git
cd file-organizer-python2. No installation needed — only uses Python standard library
3. Run the script
python file_organizer.pyBy default it organizes the folder where the script is placed. To target a different folder, edit the
target_pathvariable at the top of the script.
- Python 3.x
os— folder creation and file detectionshutil— file moving operations
I kept having to manually sort my Downloads folder every few weeks. Writing a 30-line Python script to automate it permanently was the obvious fix. It was also my first real automation project — the one that showed me how much you can do with just the Python standard library.
- Add a config file to let users define custom categories and extensions
- Add logging to show what was moved where
- Schedule it to run automatically on startup
- GUI version with folder picker
MIT License — free to use, modify, and distribute.