Lightweight Python utility to watch filesystem changes and react to them. Useful for automating tasks, live-reloading, syncing, or triggering custom handlers when files are created, modified, or deleted.
- Watch files or directories (optionally recursive)
- Filter by glob patterns or file extensions
- Debounce rapid events
- Run shell commands or Python callbacks on events
- Small, easily embeddable API and simple CLI
Install from PyPI (if published) or locally:
pip install python-filewatcher
Or from a local checkout:
pip install -e .
CLI example:
# watch a directory and run a command when a change happens
filewatcher --path ./src --pattern "*.py" --command "pytest -q" --recursive --debounce 500
- paths: list of paths to watch
- patterns: glob patterns (e.g. [".py", ".md"])
- recursive: bool, descend into subdirectories
- debounce_ms: integer, milliseconds to batch rapid events
- command: optional shell command to run on events
- callback: Python callable invoked with event metadata