Do something on an empty watch folder?

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

Moderator: Mr_Noodle

Do something on an empty watch folder? Wed Oct 29, 2008 11:48 pm • by edalzell
I have Hazel set up to monitor a folder for movies and when it finds one, to call an applescript then remove the file.

My issue is that my Applescript opens iTunes. I would iTunes to quit after everything is done. I don't want to put the 'itunes quit' in the Applescript as there may be more than one movie in the folder and I don't want to open and close iTunes multiple times.

Ideally Hazel would act on all the files in the folder at once and pass the whole list to my Applescript, but it appears it doesn't work that way.

So, is there any way to get iTunes to close only if it is open and only if the watch folder is empty?

Thanks
edalzell
 
Posts: 13
Joined: Wed Oct 29, 2008 11:43 pm

Re: Do something on an empty watch folder? Thu Oct 30, 2008 3:01 pm • by Mr_Noodle
One thing that comes to mind is if you monitor the folder above that one, you can see if the folder is empty (size is 0) and call a script to quit iTunes. It's a tad clumsy but may get the job done.
Mr_Noodle
Site Admin
 
Posts: 11195
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Do something on an empty watch folder? Thu Oct 30, 2008 5:52 pm • by edalzell
I just realized that wouldn't work as if I *wanted* to use iTunes, then it would keep getting shut down on me. What I really want is to close iTunes after Hazel is done processing ALL files in a folder.
edalzell
 
Posts: 13
Joined: Wed Oct 29, 2008 11:43 pm

Re: Do something on an empty watch folder? Wed Nov 05, 2008 2:51 pm • by Mr_Noodle
I'm not sure how Hazel would know when you are not using iTunes. It might help to somehow note if iTunes was not already running via AppleScript (in which case, you can color the folder or something) and then only quit iTunes later if the color is there. It wouldn't be perfect but may reduce many of the cases where it will quit on you.
Mr_Noodle
Site Admin
 
Posts: 11195
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Do something on an empty watch folder? Wed Nov 05, 2008 2:54 pm • by edalzell
ya, I realized after that I could use a lock file as well.
edalzell
 
Posts: 13
Joined: Wed Oct 29, 2008 11:43 pm


Return to Support