A high-performance, background automation tool that keeps your Downloads folder clean.
This is not just a script—it's a resilient System Service that runs in the background, monitoring your directories in real-time. It automatically detects new files, categorizes them based on your rules, and moves them to their designated folders instantly.
- ⚡ Event-Driven (Zero Latency): Uses the
watchdoglibrary to detect file creation instantly. No CPU-wasting "sleep loops." - 🛡️ Data Safety First: Never overwrites files. If
report.pdfexists, it auto-renames the new one toreport_16345.pdf(timestamped). - ⚙️ Smart Configuration: Fully customizable via
config.json. Change folders or extensions without touching the code. - 🐛 Robust Architecture:
- Large File Protection: Waits for large downloads (movies, ISOs) to finish writing before attempting to move them.
- Professional Logging: Tracks all actions to
organizer.loginstead of crashing console output.
- 💻 Cross-Platform: runs on macOS (launchd), Linux (systemd), and Windows.
git clone https://github.com/melihalgin1/pythonFileOrganizer.git
cd pythonFileOrganizerpip install watchdog- Locate
example_config.json. - Rename it to
config.json. - Open it and set your Source Folder (e.g., Downloads) and Target Paths.
- Note: Use double backslashes
\\for Windows paths.
- Note: Use double backslashes
- Edit the Plist:
Open
com.yourname.organizer.plist.example.- Replace
/PATH/TO/YOUR/PROJECT_FOLDERwith your actual path. - Replace
/PATH/TO/PYTHONwith your Python path (runwhich python3to find it).
- Replace
- Install:
Rename the file to
com.yourname.organizer.plistand move it:mv com.yourname.organizer.plist ~/Library/LaunchAgents/ - Start Service:
launchctl load ~/Library/LaunchAgents/com.yourname.organizer.plist - Verify:
Check the log file in your project folder:
tail -f organizer.log
-
Create Service File:
nano ~/.config/systemd/user/organizer.service(If the folder doesn't exist, create it:
mkdir -p ~/.config/systemd/user/) -
Paste Configuration:
[Unit] Description=Python File Organizer After=network.target [Service] # IMPORTANT: Use quotes around the path if it contains spaces ExecStart=/usr/bin/python3 "/home/YOUR_USER/path/to/organizer.py" Restart=always [Install] WantedBy=default.target
-
Enable & Start:
systemctl --user enable organizer systemctl --user start organizer -
Check Status:
systemctl --user status organizer
- Open Task Scheduler.
- Create a Basic Task -> "Start a Program".
- Program/script:
pythonw.exe(This runs Python without a window). - Arguments:
C:\Path\To\Organizer\start_organizer.bat(Replace this to point to start_organizer.bat where you downloaded the script). - Set the trigger to "At log on".
- Launch the task from Task Scheduler. The script should automatically detect required path variables
Your config.json should look like this:
{
"source_folder": "/Users/name/Downloads",
"rules": {
"Images": {
"target_path": "/Users/name/Pictures",
"extensions": [".jpg", ".png", ".svg"]
},
"Documents": {
"target_path": "/Users/name/Documents/Sorted",
"extensions": [".pdf", ".docx", ".txt"]
}
}
}This project is open source and available under the MIT License.