This script automatically organizes files in the Documents directory (or another specified directory)
by moving them into categorized folders based on their file extensions. It helps keep your workspace
clean and makes file management more efficient.
- Moves files based on predefined extensions.
- Categorizes files into folders such as
Images,Videos,Documents,Presentation, andZips. - Prevents clutter in your
Documentsfolder by automatically sorting new files. - Exception handling for errors when moving files.
Python 3.x installed on your system.
- Download or copy the script to your local machine.
- Ensure that the necessary folders (
Images,Videos,Documents,Presentation,Zips) exist in yourDocumentsdirectory. The script does not create them automatically.
- Run the script using Python:
python file_organizer.py- The script will scan the
Documentsdirectory (or the specified directory) and move files with known extensions into their respective folders. - If a file has an extension not listed in the script, it will be left in place.
The script currently supports the following extensions and moves them into corresponding folders:
| Extension | Folder |
|---|---|
| .png, .jpg, .jpeg, .HEIC | Images |
| .mp4, .MOV | Videos |
| .pdf, .docx | Documents |
| .pptx | Presentation |
| .zip | Zips |
You can modify the extensions dictionary in the script to include additional file types or change the destination folders.
- MacOS/Linux: The script should work as expected by default.
- Windows: The script attempts to use
USERPROFILEto determine theDocumentsfolder, but I am not 100% sure if it works correctly on Windows. If you encounter issues, try manually setting thedirectoryvariable.
- Ensure the folders exist in the
Documentsdirectory before running the script. - If a file fails to move, the script will print an error message (e.g., if a file with the same name already exists in the destination folder).
- You can modify the
directoryvariable if you want to organize files in a different location.
- Automatically create missing destination folders.
- Add support for more file extensions.
- Improve Windows compatibility.
This project is licensed under the MIT License. See the LICENSE file for details.