0

I am hoping someone could help me out. I am using a script that when pointed at a certain file in a folder, will generate a JSON file in that same folder. Below is the command used to run the script which is currently done file by file.

bash /path/to/script/PageBuilder.sh "/path/to/file/cvinfo"

I am looking to inotifywait to scan through the subdirectory and look for every cvinfo file and execute the script on that file.

This is what I have tried so far with no luck:

psttern="cvinfo"
inotifywait -m -r -e close_write --format %w%f /mnt/m/Comics/ | while read FILENAME; do
  if [[ "$FILENAME" == *${pattern}* ]]; then
    bash /mnt/m/PageBuilder/PageBuilder.sh "$FILENAME";
  fi
done&

This currently just sets up the watches and then nothing after that, even if the cvinfo file is moved to and from the folder or edited etc.

My knowledge on any of this is purely from our friend Google so i only have a very basic knowledge of how this works. I've tried looking for other posts to help but none work for my problem.

I'm using Windows but running this in a BASH terminal.

4
  • As I understood it, inotify has been made available under Windows only recently (Windows 10, don't know which patchlevel). Jul 5, 2019 at 15:33
  • Did you ever have any luck with this? I've looked at inotifywait and can get it to run on a single diredtory but could never get it to scan directories and run recursively. with just inotifywait -qm --event modify --format '%w' "/mnt/b/Action Lab/Twin Worlds (2020)/cvinfo" I've tried your script but i keep getting a syntax error. Jun 8, 2020 at 7:12
  • To be honest: no. I've never tried it recursively. Jun 8, 2020 at 9:56
  • From the man page, information about changed files is produced on stdout, according to a default pattern, at the time of the change. Jun 30, 2021 at 8:11

1 Answer 1

0

Stumbled on this while looking into a related topic... I realize this is an old post but it looks like you had a typo in the shell variable (psttern instead of pattern).

I'm not enough of an expert to know how that would fail without testing it myself, but it might fail silently (and since the ${pattern} variable might not be initialized, it would return true for any $FILENAME).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.