A simple Python script that automatically organizes files in a specified directory based on file types (e.g., Documents, Images, Videos, Music, Archives, Audio, etc.)
It can help keep your downloads folder or other directories tidy by moving files into their corresponding folders.
- Automatically creates folders based on file types (e.g.,
.pdf,.jpg,.mp4,.mp3, etc.) - Moves files into the correct folder according to their extensions
- Supports the following categories:
- Documents (
.pdf,.docx,.txt,.xlsx,.pptx) - Images (
.jpg,.jpeg,.png,.gif,.bmp) - Videos (
.mp4,.mov,.avi,.mkv) - Music (
.mp3,.wav,.flac) - Archives (
.zip,.rar,.tar,.7z) - Audio (
.aac,.ogg,.m4a) - Code (
.py,.js,.html,.css,.java,.c,.cpp) - Programs (
.exe,.msi,.bat,.sh) - Others (all unrecognized file types)
- Documents (
- Python 3.x
shutilandos(standard Python libraries)pathlib(standard Python library)
-
Clone the repository:
git clone https://github.com/`Ludusm11/file_organizer_basic.git -
Navigate to the project directory:
cd file_organizer_basic -
Ensure Python is installed:
- Check if Python is installed by running
python --versionorpython3 --version. - Install Python from python.org if needed.
- Check if Python is installed by running
-
Edit the script:
- Update the
SOURCE_DIRandDESTINATION_DIRvariables in the script to match your directory paths. - Example:
# For macOS SOURCE_DIR = "/Users/YourUser/Downloads" DESTINATION_DIR = "/Users/YourUser/Desktop/Organized" # For Windows SOURCE_DIR = r"C:\Users\YourUser\Downloads" DESTINATION_DIR = r"C:\Users\markrozum\Desktop\Organized"
- Update the
-
Run the script:
- Open a terminal or command prompt in the project folder and run:
#for mac python file_organizer_basic_mac.py #for windows python file_organizer_basic_windows.py
- Open a terminal or command prompt in the project folder and run:
-
The script will:
- Create necessary folders (Documents, Images, Videos, etc.) if they don't exist.
- Move files from the
SOURCE_DIRinto corresponding folders in theDESTINATION_DIRbased on their extensions.
Upon running the script, you’ll see output similar to the following:
You can add new file types or modify the existing categories by editing the FILE_TYPE_FOLDERS dictionary in the script:
FILE_TYPE_FOLDERS = {
'Documents': ['.pdf', '.docx', '.txt'],
'Images': ['.jpg', '.jpeg', '.png'],
'Videos': ['.mp4', '.mov'],
'Audio': ['.aac', '.ogg', '.m4a'], # Customize the Audio folder here
}This project is licensed under the MIT License. See the LICENSE file for more details.
If you would like to contribute, feel free to fork the repository and submit a pull request. Any enhancements, bug fixes, or additional features are welcome!
