Detecting if folders are empty, excluding the parent folder.

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

Moderator: Mr_Noodle

Does anybody know what might be a good rule to detect if folders inside a Folder X are empty and trash them? I did a Kind Is Folder with action Run rules on folder contents, followed by Name is not Folder X, Size is 0 bytes, on Any File, with action Move file to folder Trash. That looked logical but it doesn't work. Any suggestions?
Ton55
 
Posts: 26
Joined: Thu Nov 09, 2006 12:19 pm

I'm unclear what your second rule is. If you do "Any file", it matches everything so it doesn't make sense to have any other conditions with it. In general, though, to match empty folders, you'd have something like "Kind is Folder, Size is 0".

Also, is Hazel watching Folder X or watching the parent of Folder X? Hazel doesn't operate on the actual folder it is monitoring so you shouldn't worry about it throwing it away.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Mr_Noodle wrote:In general, though, to match empty folders, you'd have something like "Kind is Folder, Size is 0".

That won't work if a folders that would otherwise be empty contain hidden .DS_Store files.
sjk
 
Posts: 332
Joined: Thu Aug 02, 2007 5:43 pm
Location: Eugene

Actually, I believe Hazel will ignore invisible files when computing sizes. This was done specifically for cases like this where there are hidden "poop" files left around.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

That seems acceptable since I doubt many people would configure Hazel to delete "empty" folders containing invisible files of real value.
sjk
 
Posts: 332
Joined: Thu Aug 02, 2007 5:43 pm
Location: Eugene


Return to Support