Not a Hazel user, but @noisneil's screen shot suggests you can pass variables into the AppleScript. If Hazel reports which folder's change caused the workflow to run you should be able to pass that to the AppleScript to be used as a parameter in the do script -- your KM macro could then use that parameter to target the correct folder.
So you'd only need one Hazel workflow per "parent" folder (or only one if you can use multiple triggers) and a single KM macro to cope with however many folders you have.
For Hazel to monitor folders you actually need to add them manually.
For example this folder:
~/Desktop/Test
and this folder:
~/Library/Audio
Would have to both be added. Also, the developer says it's not good practice to add a folder with too much content such as the ~/ for example.
Not sure if this makes sense, but maybe I'm not getting what you're saying, especially because I'm not that knowledgeable when it comes to scripting and all that.
@Nige_S maybe what you're saying is that the KM macro would always be the same, so just 1 instance of it, and then the work of adding new folders would only be done inside Hazel? For example if I have 50 folders to monitor, I would add 50 folders to Hazel, but only 1 KM macro. Is that what you're saying?
And the 50 folders is just assuming they are all parent folders, of course, with other folders inside.
So just to make sure I understand everything:
1 - The macro you just shared will stay untouched
2 - When I want to monitor a different parent folder, I add it to hazel and I can just copy the new rule you just shared. The UUID will always be the same on all rules, regardless of the folder added to Hazel, because KM will figure out where to apply those changes.
@noisneil it's working on the original folder, but when I try to add a new folder, nothing changes. I even clicked "Run Rules Now" inside Hazel, but it's not working.
I'm no AppleScript expert, but... I wonder if it makes a difference that there seems to be a line break before "parameter"? I'm clutching at straws to be honest.
I just checked and multiple folders work ok for me.
That's not a real line break. It's just the text being wrapped, because of the available space.
Also, if that was the issue, it wouldn't work with none of the folders, because it's an exact copy on both rules. It's weird indeed...