Skip to content

VisruthR/File-organizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

File Organizer

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.)


Features

  • Config-driven mapping of extensions → folders (config.json).
  • Interactive menu (audit / sort / watch) and --auto background mode.
  • Duplicate resolution (renames files like name (1).ext).
  • Designed to be installed as a systemd service for unattended, boot-time operation.

Prerequisites

  • Python 3.8+
  • pip and a virtual environment (recommended).
  • watchdog Python package (pip install watchdog) — the watcher depends on it.
  • Systemd (if you want the service mode)

Quick start

  1. Clone or copy the project to a directory, e.g.:
git clone https://github.com/VisruthR/File-organizer
cd File-Organizer
  1. Create and activate a virtualenv (optional but recommended):
python -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install watchdog
  1. Configure extension categories in config.json. This file maps folder names to lists of extensions (example format). Edit as needed.

Usage

Interactive mode

Run the script without flags to use the interactive menu:

python organiser.py

The interactive menu supports:

  • Audit (scan and list file types),
  • Start (one-time sort),
  • Watch (start the background watcher manually).

Background / automatic mode

To run the watcher without prompts:

python organiser.py --auto

On 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.


Install as a systemd service (recommended)

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.sh

Check logs:

# live journal for the service
journalctl -u file-organizer -f

Configuration (config.json)

config.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.


Troubleshooting

  • Service appears to hang during first run If organiser.py --auto starts and the service appears to wait, it may be prompting for the watch path because watch_path.txt is missing. The installer script above ensures watch_path.txt exists 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.


Development notes & tips

  • Use the Python logging module (instead of print) if you want structured logs with levels and timestamps. Under systemd, stdout/stderr are collected by the journal automatically.
  • The script uses watchdog for 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 WorkingDirectory and ExecStart or reinstall the service.

Contributing

Fixes, suggestions, and PRs welcome. When contributing, please:

  • Keep behavior backwards-compatible where possible.
  • Add tests or reproduction steps for any bugfix.

About

A practice file organizer i created for fun.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors