Deleting empty subfolders

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

Moderator: Mr_Noodle

Deleting empty subfolders Thu Aug 23, 2012 11:23 am • by kaiijy
As many of you, i have a folder for my Movies downloaded via torrent and many of them come in folders. Inside theses folders the is the movie file and sometimes a few others, for example, Screenshots.

I've already configured Hazel to exclude all the image files from these subfolders, so as .txt and anything that ain't a MOVIE file or a SUBTITLE. Works like a charm.

Still, i'm finding it quite challenging to configure such a simple task as checking the subfolders of my Movies folder, looking for empty folders and excluding them.

I've tried using the following rules at my MOVIES folder.

#1 If KIND is FOLDER
and NUMBER OF FILES is 0

MOVE FILES to TRASH


[b]#2[b] If KIND is FOLDER

RUN RULES ON FOLDER CONTENTS


For further explanation, this is the structure:

MOVIES folder -> Rules go here
------- Film folder
---------------- Empty Folder --> the one i want to delete.
kaiijy
 
Posts: 5
Joined: Thu Aug 23, 2012 9:03 am

Re: Deleting empty subfolders Thu Aug 23, 2012 12:13 pm • by a_freyer
The number of files attribute may be counting hidden files. Generally, I have found that this works well:

Code: Select all
If (all) of the following conditions are met for (the file or folder being matched)
     Kind is folder
     Size is less than 1 byte

Do the following to the matched file or folder:
     Move to folder Trash.
     Send Growl notification with pattern "Empty folders have been cleared from (FOLDER)."


Your subfolder rule seems correct as well. Make sure to check the preview to debug your rules.
a_freyer
 
Posts: 631
Joined: Tue Sep 30, 2008 9:21 am
Location: Colorado

Re: Deleting empty subfolders Thu Aug 23, 2012 3:00 pm • by Mr_Noodle
As mentioned, "number of items" may count invisible files. That's why I added the built-in "sub-file/folder count" which filters out invisible files. I recommend trying that instead.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Deleting empty subfolders Wed Nov 20, 2013 6:49 pm • by esojotrebla
kaiijy wrote:As many of you, i have a folder for my Movies downloaded via torrent and many of them come in folders. Inside theses folders the is the movie file and sometimes a few others, for example, Screenshots.

I've already configured Hazel to exclude all the image files from these subfolders, so as .txt and anything that ain't a MOVIE file or a SUBTITLE. Works like a charm.

Still, i'm finding it quite challenging to configure such a simple task as checking the subfolders of my Movies folder, looking for empty folders and excluding them.

I've tried using the following rules at my MOVIES folder.

#1 If KIND is FOLDER
and NUMBER OF FILES is 0

MOVE FILES to TRASH


[b]#2[b] If KIND is FOLDER

RUN RULES ON FOLDER CONTENTS


For further explanation, this is the structure:

MOVIES folder -> Rules go here
------- Film folder
---------------- Empty Folder --> the one i want to delete.


How did you handle cleaning up files that come with torrent downloads? (nfo, txt, screenshots, samples) Normally I don't download them in the first place but when using magnet links I don't see the option of picking what to download. This is what I have:

Rule #1 Remove empty (my logic tells me this should be third but it only works when it goes first)
- If all conditions are met
-- Kind is folder
-- Sub-file/folder count is 0
-Then
-- move to trash

Rule #2 Dive into subfolders
- if all conditions are met
-- kind is folder
- then
-- run rules on folder contents

Rule #3 Movie mover
- if any condition is met
-- kind is movie
-- extension is mkv
-then
-- move to folder movies

How do I delete any leftovers?

Things to consider: this is run in the downloads folder, where I also download pretty much everything. I though about specifically looking for image and nfo files, or video files containing the word sample, but I'm afraid this rule will affect other files in the downloads folder and they'll get deleted.

How do I make sure a certain rule is only run for the video torrent download?

Thanks
esojotrebla
 
Posts: 2
Joined: Wed Nov 20, 2013 6:23 pm

Re: Deleting empty subfolders Thu Nov 21, 2013 3:34 pm • by Mr_Noodle
Unless you can figure out a way to differentiate between these torrent downloads and other ones, you may want to consider having your torrents download into their own folder and have a separate set of rules for that.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support