A small, config-driven file organizer for personal use. It watches a folder (default: ~/Downloads) and moves files into categorized subfolders based on extension rules in config.json. The watcher uses watchdog and can run interactively or as a background systemd service.
(Implementation notes and behavior are drawn from the project files: config.json and organiser.py.)
- Config-driven mapping of extensions → folders (
config.json). - Interactive menu (audit / sort / watch) and
--autobackground mode. - Duplicate resolution (renames files like
name (1).ext). - Designed to be installed as a systemd service for unattended, boot-time operation.
- Python 3.8+
pipand a virtual environment (recommended).watchdogPython package (pip install watchdog) — the watcher depends on it.- Systemd (if you want the service mode)
- Clone or copy the project to a directory, e.g.:
git clone https://github.com/VisruthR/File-organizer
cd File-Organizer- Create and activate a virtualenv (optional but recommended):
python -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install watchdog- Configure extension categories in
config.json. This file maps folder names to lists of extensions (example format). Edit as needed.
Run the script without flags to use the interactive menu:
python organiser.pyThe interactive menu supports:
- Audit (scan and list file types),
- Start (one-time sort),
- Watch (start the background watcher manually).
To run the watcher without prompts:
python organiser.py --autoOn first --auto run, the script will prompt to choose a watch path and save it to watch_path.txt so future --auto runs do not prompt.
There is a Auto.sh file in this folder to fully automate the setting up process of background serviece
Make executable and run:
chmod +x Auto.sh
./Auto.shCheck logs:
# live journal for the service
journalctl -u file-organizer -fconfig.json controls how files are grouped. Example structure (from the project): each key is a folder name and its value is a list of extensions (including the dot), e.g. "Images": [".jpeg", ".jpg", ".png", ".webp"]. Edit to add or change categories.
-
Service appears to hang during first run If
organiser.py --autostarts and the service appears to wait, it may be prompting for the watch path becausewatch_path.txtis missing. The installer script above ensureswatch_path.txtexists so the service will not block on stdin. -
Partially-downloaded files (.crdownload / .part) The watcher ignores common temporary download extensions, but large downloads may still trigger multiple events. The script adds a short
sleep(1)before processing to reduce race conditions; for aggressive reliability you may want to extend the delay or employ a file-size-stability check. -
Permissions The service runs as the user that installed it (the installer sets
User=automatically). Ensure the user has read/write permission on the watched folder and any destination folders.
- Use the Python
loggingmodule (instead ofprint) if you want structured logs with levels and timestamps. Under systemd, stdout/stderr are collected by the journal automatically. - The script uses
watchdogfor filesystem events; tests are easiest with small files dropped into the watched folder. - If you move the project directory after installing the service, update the service's
WorkingDirectoryandExecStartor reinstall the service.
Fixes, suggestions, and PRs welcome. When contributing, please:
- Keep behavior backwards-compatible where possible.
- Add tests or reproduction steps for any bugfix.