Page 1 of 1

Solved: Trigger an AppleScript when a folder is empty

PostPosted: Tue Jul 15, 2014 3:03 pm
by DC1
Hi !

Need to run an AppleScript after all files of a folder have been processed and the folder is empty again.
How do I trigger this from within Hazel ?

Thanks,
DC

Re: Trigger an AppleScript when a folder is empty

PostPosted: Wed Jul 16, 2014 12:37 pm
by Mr_Noodle
You'd probably need to have Hazel monitor the folder above that folder and then have a rule to match it when it's empty. You'll probably also need to have Hazel go into subfolders (see sticky article) to process the actual files within.

Re: Trigger an AppleScript when a folder is empty

PostPosted: Wed Jul 16, 2014 1:05 pm
by DC1
That is exactly what I wanted to avoid...
I was hopeing there would have been an easier solution.

Am I correct with this approach:
- poll the folder above the target folder
- test for folder name and count of files in subfolder
?

And while we are at it: is there a way to copy all Finder tags from an encapsulating folder to the files inside of that folder ?

Thanks
DC

Re: Trigger an AppleScript when a folder is empty

PostPosted: Wed Jul 16, 2014 1:41 pm
by DC1
DC1 wrote:Am I correct with this approach:
- poll the folder above the target folder
- test for folder name and count of files in subfolder
?

Tested and works. Downside: polling folder needs to be within a specific subfolder.

Re: Solved: Trigger an AppleScript when a folder is empty

PostPosted: Thu Jul 17, 2014 11:20 am
by Mr_Noodle
You can match against the enclosing folder by holding down option while clicking the + key to create a new condition. That creates a nested condition where you can specify the target. That said, there's no way to capture all the tags. You'll have to use a script to do something like that.