Deleting empty folders

Talk, speculate, discuss, pontificate. As long as it pertains to Hazel.

Moderators: Mr_Noodle, Moderators

Deleting empty folders Sun May 06, 2007 8:47 am • by matt
Hi, first let me say this is a great piece of software! Just bought a license last week.

Is there a way with the current version to check for empty folders? I have an xbox that I use to watch TV shows and movies that I have put on my computer. When I am done watching a series it would be cool to have the folder deleted. For example, if I finish watching season 1 of The Office, the 'season 1' folder will be empty and I want it deleted.

Not sure how well this would work since there may be a .ds_store file still there.

Any ideas? This would be especially helpful with the new regex sorting in 2.0
matt
 
Posts: 6
Joined: Wed May 02, 2007 8:30 am

Wed May 09, 2007 9:57 pm • by Mr_Noodle
Ah, yes. A zero size would not indicate an empty folder, for issues independent of the .ds_store files. I'll figure out how to work it into the existing scheme.

Thanks for purchasing and for the feedback.

P.S. Move this from the Tips & Tricks forum as it's more appropriate here.
Mr_Noodle
Site Admin
 
Posts: 11193
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Sat Jul 07, 2007 9:35 pm • by IDontDoWindows
Code: Select all
on hazelProcessFile(aFolder)
   tell application "Finder"
      set theContents to entire contents of aFolder
      if theContents = {} then
         delete aFolder
      end if
   end tell
end hazelProcessFile
IDontDoWindows
 
Posts: 57
Joined: Sun Jan 07, 2007 5:43 am

Mon Jul 09, 2007 3:33 pm • by Mr_Noodle
Just a note that 2.0 now filters out invisible files from size calculations. That means that folders with a .DS_Store and other similar files will still be considered empty.
Mr_Noodle
Site Admin
 
Posts: 11193
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

... how about subfolders Tue Aug 14, 2007 5:21 pm • by tjevans
Is there a way to get Hazel to delete empty subfolders? I use saft that saves all downloads to a subfolder that has the download date as the name (i.e. all downloads on August 14 go into the 8/14/07 subfolder in my downloads folder).

Will the code above do that? If so, what do I do with that code?
tjevans
 
Posts: 2
Joined: Tue Aug 14, 2007 5:15 pm

Wed Aug 15, 2007 2:03 pm • by Mr_Noodle
I believe it will work without any scripting.

Something like:

"If Kind is Folder and Size is 0, Move to Trash"

If you want to descend and get to folders further down, you would add a rule like:

"If Kind is Folder, Run Rules on Folder Contents"

You would want this rule to come after the first rule since you only want to descend if it isn't empty.

Let me know how it works out for you.
Mr_Noodle
Site Admin
 
Posts: 11193
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Wed Aug 15, 2007 5:46 pm • by tjevans
Thanks, Mr_Noodle! Not only did that answer my question, but after seeing it in action, I now understand the help file on processing subfolders a lot better!
tjevans
 
Posts: 2
Joined: Tue Aug 14, 2007 5:15 pm

Moving Empty folders Fri Sep 28, 2007 6:40 am • by Thraxmanius
Just a thought, you will need to add a date specific filter in here too otherwise every-time you create a folder (say on the desktop) Hazel will move it to the trash before you get to use it.

Regards

Thrax
http://www.maccoder.co.uk
Thraxmanius
 
Posts: 1
Joined: Fri Sep 28, 2007 6:37 am

Re: Deleting empty folders Mon Dec 24, 2012 5:06 pm • by nleco
i was looking for a way to delete empty folders and wasnt sure about hidden files. thanks for the info!

i love this app. I recommended it to a friend and he bought it and is in love with it too.
nleco
 
Posts: 8
Joined: Thu Apr 05, 2012 2:34 am


Return to Open Discussion