Page 1 of 1

Detecting if folders are empty, excluding the parent folder.

PostPosted: Mon Apr 21, 2008 8:18 am
by Ton55
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?

Re: Detecting if folders are empty, excluding the parent folder.

PostPosted: Mon Apr 21, 2008 5:26 pm
by Mr_Noodle
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.

Re: Detecting if folders are empty, excluding the parent folder.

PostPosted: Tue Jun 03, 2008 5:56 pm
by sjk
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.

Re: Detecting if folders are empty, excluding the parent folder.

PostPosted: Wed Jun 04, 2008 2:20 pm
by Mr_Noodle
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.

Re: Detecting if folders are empty, excluding the parent folder.

PostPosted: Wed Jun 04, 2008 6:17 pm
by sjk
That seems acceptable since I doubt many people would configure Hazel to delete "empty" folders containing invisible files of real value.