Solved: Trigger an AppleScript when a folder is empty

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

Moderator: Mr_Noodle

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
Last edited by DC1 on Wed Jul 16, 2014 1:43 pm, edited 1 time in total.
DC1
 
Posts: 5
Joined: Tue Jul 15, 2014 2:59 pm

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.
Mr_Noodle
Site Admin
 
Posts: 11866
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Trigger an AppleScript when a folder is empty 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
DC1
 
Posts: 5
Joined: Tue Jul 15, 2014 2:59 pm

Re: Trigger an AppleScript when a folder is empty 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.
DC1
 
Posts: 5
Joined: Tue Jul 15, 2014 2:59 pm

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.
Mr_Noodle
Site Admin
 
Posts: 11866
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support