- Download and install python 3
- Execute: pip3 install watchdog
- Execute: python3 main.py --help
r-santos@rafmbp ~/d/p/watchnexecute-python> python3 main.py --help
usage: main.py [-h] dir cmd
Watch directory and execute cmd.
positional arguments:
dir directory to watch
cmd cmd to be executued for each new file
optional arguments:
-h, --help show this help message and exit
start:
python3 main.py ./ "cat %s | grep thingy"
output:
watching directory: "./"
will execute "cat %s | grep thingy" for directory modified files.
input:
touch example.test
output:
executing "cat ./example.test | grep thingy"
input:
echo "thingy" >> example.test
output:
executing "cat ./example.test | grep thingy"
thingy
r-santos@rafmbp ~/d/p/watchnexecute-python> python3 main.py ./ "open -a Visual\ Studio\ Code %s"
watching directory "./"
will execute "open -a open -a Visual\ Studio\ Code %s" for directory modified files.