Delete All Empty Subfolders

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

Moderator: Mr_Noodle

Delete All Empty Subfolders Wed Feb 17, 2010 11:35 pm • by AustinMatherne
I have an applescript that deletes watched tv shows from itunes along with the corresponding video files in "Users/Username/Music/iTunes/iTunes Music/TV Shows". The only problem is it doesn't delete the folders the files are contained in. For example, the fourth episode of the sixth season of the show Lost would be located "Users/Username/Music/iTunes/iTunes Music/TV Shows/Lost/Season 6/04 The Substitute.m4v", and the Applescript I have will delete the m4v file, but it leaves the empty folders "Season 6" and "Lost". What I'd like Hazel to do is delete the season and show folders if they're empty.

I thought I knew how to do this, but apparently not because it's not deleting any folders.

I'm using TV Shows as the folder.
The first rule is "If all of the following conditions are met" "Kind is Folder" then "Do the following" "Run rules on folder contents".
The second rule is "If all of the following conditions are met", "Kind is Folder" and "Size is 0 bytes" then "Do the following" "Move file to folder: Trash".

What am I doing wrong?
~ Austin
AustinMatherne
 
Posts: 6
Joined: Wed Jan 27, 2010 12:41 am
Location: Stamford, Connecticut, USA

Re: Delete All Empty Subfolders Fri Feb 19, 2010 5:27 pm • by Mr_Noodle
Any particular file/folder can only match one rule. So, all folders are matching the first rule and never get to the second. If you reverse the order of the rules, then it should work as you expect. Try using the preview function to test the rule logic.
Mr_Noodle
Site Admin
 
Posts: 11865
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Delete All Empty Subfolders Fri Feb 19, 2010 5:46 pm • by AustinMatherne
I knew it had to be something stupidly simple.

Thanks,
~ Austin
AustinMatherne
 
Posts: 6
Joined: Wed Jan 27, 2010 12:41 am
Location: Stamford, Connecticut, USA


Return to Support