0

There are a lot of similar posts out there, but none that does exactly what I want: I want a simple script, that watches a folder on a Mac for changes and passes the filename of the modified file to command/script when changes are detected.

The tool inotifywait doesn't exist on a mac. Folder events or fswatch or watchdog seem to be getting close, but it turns out they only watch folders or only return the folder name. watchdog might be doing what I need, but I could only find commands like this

watchmedo shell-command --recursive --command='echo ${watch_src_path}' .

which again only passes the folder name in the variable watch_src_path. Does anyone know how to get it (or another program) to pass on the file name of the changed file?

reevesy
  • 3,452
  • 1
  • 26
  • 23
John Smith
  • 1,059
  • 1
  • 13
  • 35

1 Answers1

0

Even if the question is very old, it may be useful to other people looking for the same functionality. I wrote fsw exactly to fill this gap. fsw will give you the name of the changed paths and the type of change event.

Hope this helps.

Edited: fsw was merged with fswatch.

Enrico M. Crisostomo
  • 1,653
  • 1
  • 17
  • 26