Run script when folder content changes

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

Run script when folder content changes Mon Jan 16, 2023 8:45 am • by Danny Wyatt
Using Hazel and Keyboard Maestro I want to get a notification when Dropbox is not running.
Basically Hazel would check whenever a new file/folder is added/removed from the folder, or a file/folder changed, such as the name or something like that, and if so, it will run a Keyboard Maestro macro that checks if Dropbox is running or not. If not, it will display a notification.

I tried the sub-file/folder count did change inside the Dropbox folder, but that doesn't work.
It works if I add my Home folder, which is where Dropbox resides, and then I add:
If the sub-file/folder count did change
If the kind is a folder
If the name is Dropbox

Is this the only way or can I make it work without including the Home folder, just the Dropbox folder?
Danny Wyatt
 
Posts: 25
Joined: Wed Mar 23, 2022 7:39 am

Re: Run script when folder content changes Mon Jan 16, 2023 10:56 am • by Mr_Noodle
If you want a rule to match the folder, it can't be the folder being monitored. Rules only apply to items inside the monitored folder so your second solution is correct.

That said, you can just monitor the Dropbox folder, set up a rule to match "any file" which will trigger anytime a file is added or removed. Not so much if a file or folder changed though. If you want to catch all changes, check the manual for folder syncing. There is an example rule there for detecting that. You can change the actions to do something besides sync.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Run script when folder content changes Mon Jan 16, 2023 11:10 am • by Danny Wyatt
Mr_Noodle wrote:If you want a rule to match the folder, it can't be the folder being monitored. Rules only apply to items inside the monitored folder so your second solution is correct.

That said, you can just monitor the Dropbox folder, set up a rule to match "any file" which will trigger anytime a file is added or removed. Not so much if a file or folder changed though. If you want to catch all changes, check the manual for folder syncing. There is an example rule there for detecting that. You can change the actions to do something besides sync.


Thank you. I will check the manual. Meanwhile I think I can achieve the same thing by using this on my Dropbox folder, don't you think? Then I would be able to remove the Home folder completely.
Image
After this rule, I have the rule to process the sub folders as well.
Danny Wyatt
 
Posts: 25
Joined: Wed Mar 23, 2022 7:39 am

Re: Run script when folder content changes Tue Jan 17, 2023 10:29 am • by Mr_Noodle
Are tag changes the only thing you want to trigger on? That differs from what you originally stated.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Mr_Noodle wrote:Are tag changes the only thing you want to trigger on? That differs from what you originally stated.

Basically I would like to monitor any change inside that folder so if I make a change there and Dropbox is not running, that would not be synced to their servers and I would like to know that immediately. So the only modifications I see available for that are: file/folder/tag is added/deleted/modified.
Danny Wyatt
 
Posts: 25
Joined: Wed Mar 23, 2022 7:39 am

Re: Run script when folder content changes Fri Jan 20, 2023 10:31 am • by Mr_Noodle
As stated earlier, check the manual for syncing a folder. There's an example there that shows conditions on how to match if anything changes in a folder hierarchy.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support