This is a simple Python script that organizes files in a specified folder by their file extensions. It's useful for keeping your directories clean and easy to navigate.
The script scans all the files in a given directory and moves them into subfolders based on their file types (e.g., .jpg files into a folder named jpg, .pdf into pdf, etc.).
- Lists all items in the source directory.
- Ignores any subdirectories (works only on files).
- Extracts the file extension of each file.
- Creates a new folder for each extension (if not already present).
- Moves the file into the corresponding folder.
If your folder contains: snackBOT/ ├── image1.png ├── doc1.pdf ├── music.mp3 ├── archive.zip
After running the script, it becomes: snackBOT/ ├── png/ │ └── image1.png ├── pdf/ │ └── doc1.pdf ├── mp3/ │ └── music.mp3 ├── zip/ │ └── archive.zip
- Change the
source_filepath in the script to your folder path:source_file = "D:\\PROJECTS\\LOGO\\snackBOT"
- Run the script: python file_organizer.py
Python 3.x
No external libraries needed (uses os and shutil)
Make sure to backup your files before running the script, especially if the folder contains important or system files.
Made by Suman Gouda as a part of learning Python and automating basic file tasks.