Move an avi and then delete the original folder?

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

Moderator: Mr_Noodle

Hi,

I love your software but scratching my head at just one thing...

I have a series of unarchived movies in my Downloads folder which all sit within individual folders. For example, Downloads>MovieFolder>Movie.avi

I'd like Hazel to automatically detect the avi's, move them individually to my Movies folder and then immediately delete the original folder (Downloads>MovieFolder) and the remaining contents.

Moving the avi files has proved to be easy, but I'm stuck at how I might delete the original parent folders.

I've tried using Mr_Noodle's Apple Script (viewtopic.php?p=1545#p1545) but it's targeting the parent folder of the moved file instead (User>Movies instead of Downloads>MovieFolder)

Could you please tell me how I might modify it, or better still an easier way to do this?
colinmckinney
 
Posts: 2
Joined: Sat Sep 24, 2011 12:11 pm

Try using a separate rule to match folders that are empty (size = 0 or number of items = 0). Note that the latter attribute is a Spotlight attribute so you need to select "Other..." and find it in the list.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Thanks, that works great for folders which contain only avi files. The problem lies when there are other random files left over such as html, nzb and nfo.

I there a way to delete a folder (regardless of it's contents) if a certain file type has just been removed from it?
colinmckinney
 
Posts: 2
Joined: Sat Sep 24, 2011 12:11 pm

Well, you may be able to rig something in the upcoming 3.0 (see the beta forums if you are interested in testing).

For 2.x, you would probably have to modify the Applescript to target the parent folder at the source. It would require some scripting knowledge though.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Mr_Noodle wrote:Well, you may be able to rig something in the upcoming 3.0

This thread seems to match my usecase. Is there anything in 3.0 that helps? Thank you.
nwehrle
 
Posts: 4
Joined: Sun Apr 15, 2012 4:05 pm

Not quite, unfortunately. If you look at that old Applescript (which still works and is useful in some cases), it retargets the actions so that subsequent actions are run on a different entity than the one originally matched.

Most of the cases where this type of thing was needed is now handled by allowing conditions to match sub-files or the enclosing folder. For instance, people wanted to color a folder if it contained mp3 files. Before, you would have to match the mp3, then retarget using that script to target the enclosing folder, then color the folder. Note that this would be inefficient as it would color the folder for every mp3 in the folder. Now, you can just say if this folder has any mp3s, color the folder.

I will confess this, though. During development, I did create an action to retarget a file. You could retarget to some pre-canned things like the enclosing folder, but you could also specify a folder and a pattern. So, you could, for instance, target another file with the same name in another folder or the same name but different extension in the same folder. The problem was that it was hard to explain how the action worked exactly plus the interface for it made it even harder. For now, I've disabled it until I can figure out (a) that it is really needed and (b) how to work it so that it is understandable. If you have feedback on it, please post here. In particular, if you have specific use cases or specific ideas on how to present the interface.

Right now, removing the empty folders in another pass is the way to go.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support