A simple Python script to automatically organize files in a directory by their file type (extension).
Each file type gets its own folder, making the directory clean and structured.
- Scans a base directory for files
- Detects file extensions
- Creates folders named after each extension (e.g.,
PDF,TXT,JPG) - Moves files into their respective folders
- Skips duplicates if the file already exists in the destination
- Set the
base_pathvariable to the folder you want to organize:base_path = r"C:\Users\admin\abc"
abc/ |--- report.pdf |--- notes.txt |--- image.jpg
abc/ |--- PDF/report.pdf |--- TXT/notes.txt |--- JPG/image.jpg