Folder trigger on subfolders


Is there a way to use folder trigger on subfolders?


I don’t know a way to do this with KM.

Noodlesoft’s Hazel is specialized in folder watching and can do it, for example like this:

Thank you but I already tried that. It is described here.

The caveat of Hazel is that it does nothing when you move the file outside the watched folder or subfolder. It also ignores file rename. Keyboard Maestro reacts on both events but just on a single folder.

It’s a bit tricky but with three rules I could achieve what you want:

The ruleset has to be applied to the parent folder and it will watch the file count and file name changes in all contained subfolders:

  1. File added/removed in any subfolder:

  2. Going into subsubfolders:

  3. Checking for name changes:

This is not very intuitive. I had expected that the “Go to Subfolders” rule has to go last, but it didn’t work for some reason.

(I also noticed that Hazel’s notifications are buggy. They show up in the log but are not always displayed by the Notification Center. That’s why I used AppleScript notifications.)

I tried to keep this post short, since it doesn’t have much to do with KM. I hope it helps nevertheless.

Thank you for your effort but it does not work. Preview shows just go to subfolders:

As you said this topic doesn't have much to do with KM. I will move the discussion to the noodlesoft forum.

For the time beeing the best solution I found is a KM Execute a Shell Script action triggered At login:
fswatch -or -0 /name/of/folder/ | xargs -0 -n1 -I{} your command goes here

I use AppleScript to run ChronoSync job:
fswatch -or -0 /Users/h9/Documents/ | xargs -0 -n1 -I{} osascript -e 'tell application "ChronoSync Scheduler" to Synchronize item 3 of scheduled items'

You need a fswatch for that. It is available on Brew.

1 Like

Strange. It definitely works here (tested with 2 folder levels):

I didn’t know that one. It may indeed come in very handy, especially in conjunction with KM.

Thanks for the pointer!


This is the Hazel ruleset from above: (4.0 KB)