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
βοΈ techmantrapatil@gmail.com