A Python script that automatically organizes files in a directory by sorting them into folders based on their file extensions.
This script helps you keep your directories clean and organized by automatically sorting files into appropriate folders based on their file types. It creates folders for different categories of files (documents, images, videos, etc.) and moves files into them accordingly.
- Automatically creates folders based on file types
- Sorts files into appropriate folders based on their extensions
- Handles various file types including:
- Documents (Word, Excel, PDF, etc.)
- Images (JPG, PNG, GIF, etc.)
- Audio files (MP3, WAV, etc.)
- Video files (MP4, AVI, etc.)
- Compressed files (ZIP, RAR, etc.)
- Design files (DWG, EPS, etc.)
- Development files (Python, Java, etc.)
- Creates an 'others' folder for unrecognized file types
- Provides detailed operation summary
- Handles duplicate files safely
- Python 3.6 or higher
- pathlib module (included in Python standard library)
- Clone this repository or download the script:
git clone https://github.com/yourusername/file-organizer.git- Copy the script in the desired folder.
- Basic usage (organizes current directory):
python sort-files.py- To create a desktop shortcut for easy access:
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut("$env:USERPROFILE\Desktop\Sort Files.lnk")
$Shortcut.TargetPath = "python"
$Shortcut.Arguments = "sort-files.py"
$Shortcut.Save()Created folder: documents
Moved document.pdf to documents
Created folder: images
Moved photo.jpg to images
Warning! file.txt already exists in documents
...
Operation summary:
Files successfully moved: 15
Files not moved: 2
- Microsoft Office files (.doc, .docx, .xls, .xlsx, .ppt, .pptx)
- PDF files (.pdf)
- Text files (.txt)
- OpenDocument formats (.odt, .ods, .odp)
- Common formats (.jpg, .jpeg, .png, .gif)
- Raw formats (.raw, .cr2, .nef)
- Design formats (.ai, .psd)
- Common formats (.mp3, .wav, .wma, .aac)
- Lossless formats (.flac)
- Common formats (.mp4, .avi, .mkv, .mov)
- Web formats (.webm)
- Source code files (.py, .java, .cpp, .html, .css, .js)
Feel free to fork this repository and submit pull requests to improve the script. You can also open issues if you find any bugs or have suggestions for improvements.
This project is licensed under the MIT License - see the LICENSE file for details.