A smart and lightweight Python automation script that automatically organizes your files into categorized subfolders based on their extensions. Say goodbye to messy "Downloads" folders — everything gets sorted neatly in seconds!
1️⃣ You input the folder path you want to organize.
2️⃣ The script scans all files (ignoring subfolders).
3️⃣ It creates subfolders based on file types and moves files accordingly:
| Category | File Extensions |
|---|---|
| Images | .jpg, .jpeg, .png, .gif, .bmp, .tiff |
| Documents | .pdf, .doc, .docx, .txt, .xls, .xlsx, .ppt, .pptx |
| Audio | .mp3, .wav, .aac, .flac |
| Videos | .mp4, .mov, .avi, .mkv |
| Archives | .zip, .rar, .tar, .gz, .7z |
| Scripts | .py, .js, .html, .css, .sh, .bat |
| Others | Any unrecognized file type |
Files with unknown or uncommon extensions are moved into an “Others” folder.
git clone https://github.com/mantrapatil03/python-beginner-friendly-projects.git
cd python-beginner-friendly-projects/file-organizerpython file_organizer.py
3️⃣ Enter your target folder path:
Enter the path of the folder to organize: /home/user/Downloads
✅ Done! Your files will now be automatically categorized into subfolders.
Before:
Downloads/
├── photo1.jpg
├── song.mp3
├── document.pdf
├── script.pyAfter:
Downloads/
├── Images/
│ └── photo1.jpg
├── Audio/
│ └── song.mp3
├── Documents/
│ └── document.pdf
├── Scripts/
│ └── script.py
- This script moves files (does not copy).
- Make sure you have write permissions for the directory.
- Always test on a small sample folder first to verify results.
Mantra Patil
💼 LinkedIn: https://www.linkedin.com/in/mantrapatil25