Skip to main content

CLI tool for monitoring changes, additions, removals in files and directories and optionally running commands on specified operations.

Project description

📁🔍 fdw - CLI tool for watching files and directories changes

Command line tool for monitoring changes, additions and removals in files and directories. It also offers the option to run commands on specified operations.

Screenshot of fdw program running

Instalation

No external dependecies required! 🚫🧰

$ pip3 install file-directory-watcher

PyPI

Tips:

  • 💡 It is recommended to install it globally, so you can use it from anywhere.

Usage

fdw is a command-line tool and does not provide any importable modules.

$ fdw pattern [pattern ...] [--exclude pattern ...] [options]

Examples

Simple

$ fdw "**/*.py" --interval 1s --on-file-change "echo Python file changed"

Tips:

  • 💡 Surround patterns with quotes to prevent shell expansion.
  • 💡 You can use short versions of options. e.g. -i instead of --interval.

Advanced

$ fdw \
"src/**/*.py" \
--exclude "/home/username/project/src/**/__pycache__/**/*" \
--interval 1s \
--background \
--only file_added \
--on-file-add "git add %relative_path" \
--verbosity full \

Tips:

  • 💡 Instead of exluding a folder with large number of files, try including only the files you are interested in. This will improve the performance and reduce CPU usage.

Options

Patterns for files and directories

Option Value Description
(positional) pattern Glob pattern to watch for changes. You can specify one or more patterns.
--exclude Glob patterns to exclude from watching. You can specify one or more exclusion patterns.

Configuration options

Option Value Description
-i,
--interval
e.g. 0.5s, 1m, 2h30m, 1d12h Interval between running the watcher. Default: 1s.
-d,
--delay
Delay between files. Default: 0s.
-b,
--background
- Run commands in the background as non-blocking processes. The fdw process itself is stil in foreground.
--only file_changed, file_added, file_modified, file_removed, directory_changed, directory_added, directory_modified, directory_removed
or short versions
fc, fa, fm, fr, dc, da, dm, dr
Operations to watch for. Default: all.
--ignore Operations to ignore. Default: none.
--fcm,
--file-compare-method
mtime, size, md5, mode, uid, gid Methods to compare files. Default: mtime
--dcm,
--directory-compare-method
mtime, mode, uid, gid Methods to compare directories. Default: mtime
-v,
--verbosity
limited, normal, full Set output verbosity. Default: normal.
--nc,
--no-color
- Disable colored output.

Commands to run on specified operations

Option Value Description
--oc,
--on-change
command Commands to run when a file or directory is added, modified, or removed.
--oa,
--on-add
Commands to run when a file or directory is added.
--om,
--on-modify
Commands to run when a file or directory is modified.
--or,
--on-remove
Commands to run when a file or directory is removed.
--ofc,
--on-file-change
Commands to run when a file is added, modified, or removed.
--ofa,
--on-file-add
Commands to run when a file is added.
--ofm,
--on-file-modify
Commands to run when a file is modified.
--ofr,
--on-file-remove
Commands to run when a file is removed.
--odc,
--on-directory-change
Commands to run when a directory is added, modified, or removed.
--oda,
--on-directory-add
Commands to run when a directory is added.
--odm,
--on-directory-modify
Commands to run when a directory is modified.
--odr,
--on-directory-remove
Commands to run when a directory is removed.

For all commands, you can use the following variable expansions:

Variable Expanded value Description
%name e.g. README.md The name of the file or directory.
%relative_path e.g. ../../files/README.md The relative path of the file or directory.
%absolute_path e.g. /home/user/files/README.md The absolute path of the file or directory.

Other options

Option Value Description
--version - Shows program's version number and exit.
-h, --help - Show help message and exit.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

file-directory-watcher-0.0.10.tar.gz (115.4 kB view hashes)

Uploaded Source

Built Distribution

file_directory_watcher-0.0.10-py3-none-any.whl (12.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page