Moving Folders with Hazel

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

Moderator: Mr_Noodle

Moving Folders with Hazel Sun May 10, 2015 6:15 am • by xieem
Dear Hazelusers,

After one year of avoiding using Hazel (I did purchase it but never played around with it), I finally made the step and started to bring some automatization in my system.

First of all I would like to thank Mister Noodle for this amazing piece of software (where have you been all my life?).

But as in all things when trying and testing I have hit some walls to continue my workflow.

I'll explain my setup very brief and simple share some of my rules and post the questions where I would need some help.

First of all: My setup

Let me start with the fact that I don't rename files, I don't like it, it's a personal thing, does it make my config much more confusing, probably it will.

So here we go:

Step 1, creating the downloads folder

For my download folder I just use ./downloads/movies ./downloads/tv

Step 2a, extracting the files - TV


For extracting the files I don't use NoodleSoft build in unarchiver, I use a script named Unrarall https://github.com/arfoll/unrarall. It is very easy to use and it allows to get rid of your rar files, and all the extra stuff that comes with downloaded files, there are solutions in the help section if you can't get it up and running.

How does the rule look like?

If all of the following conditions are met
Kind is Folder

Run rules on folder contents
Run shell script -> embedded script

Code: Select all
cd /users/username/download_folder
./unrarall --clean=all --output ~/Downloads_folder/sorted_folder/TV ~/Downloads_folder/sorted_folder/TV


Step 3a, sorting - TV

Since I don't rename my files I have a very hectic setup.

Let's say we have a folder Noodle.Soft.S01E01.720p.HDTV.X264-HAZEL

After extracting the file will be moved from ~/Downloads_folder/sorted_folder/TV/Noodle.Soft.S01E01.720p.HDTV.X264-HAZEL => ~/Downloads_folder/sorted_folder/TV/Noodle.Soft.S01E01.720p.HDTV.X264-HAZEL.mkv

Now the moving part

I call this rule Move TV Shows 2 Title (Noodle.Soft)

My rule is

If all of the following conditions are met

If any of the following conditions are met for "the current file or folder"
kind is Matroska Video File
Kind is subtitles file
Name matches • Showname.• Showname part 2.S• Season 1E• Episode.• Quality.• Source.• Codec-• Groupname

breakdown: showname => custom text / Anything ... Showname part 2 => custom text / Anything Season => custom text / number Episode => custom text / number Quality => custom text / letters & digits Source => custom text / word Codec => custom text / Letters & Digits Groupname => custom text / word (any information here could be helpful if word could be replaced with anything (in case group name with letters & digits would appear) (please provide feedback).

The bold underlined . are important, cause that's what people most of the time overlook, Hazel scans part by part and if one of these parameters is missing your file won't be moved.

Next part of the rule

Move to folder => here is your moving dir
Sort into subfolder with pattern • Showname.• Showname part 2 ▸s• Season 1 (based on the parameters above)

Step 2b, Extracting the files - MOVIES

This rule is almost identical as the TV rules but I extract my movies in the same folders as the dir

Run rules on folder contents
Run shell script -> embedded script

Code: Select all
cd /users/username/download_folder
./unrarall --clean=all new


Step 3b, sorting - MOVIES

Let's say we have a folder Noodle.Soft.S01E01.720p.HDTV.X264-HAZEL

After extracting the file will be moved from ~/Downloads_folder/sorted_folder/MOVIES/Noodle.Soft.2015.720p.BluRay.X264-HAZEL => ~/Downloads_folder/sorted_folder/MOVIES/Noodle.Soft.2015.720p.BluRay.X264-HAZEL/Noodle.Soft.2015.720p.BluRay.X264-HAZEL.mkv

So as you can see the MOVIE starts with N

My setup on my storage unite is in folders 0-9 -> A B C ....... Z

So how do I move them to the specific folder

My rule:

If all of the following conditions are met
If any of the following conditions are met for the current file or folder
Kind is Matroska Video File
Kind is Subtitles File
Name Matches N• MovieTitle

MovieTitle => ... (anything)

Move To Folder Movies
Sort Into subfolder with pattern N▸

OK, BUT

Where is the problem here:

First of all:

In this rule only the file gets moved, now my question is How can I make Hazel create/move the folder on the destination folder (only for the movie part necessary, it will create on the destination folder N/Noodle.Soft.2015.720p.BluRay.X264-HAZEL.mkv and not, like I want N/Noodle.Soft.2015.720p.BluRay.X264-HAZEL/Noodle.Soft.2015.720p.BluRay.X264-HAZEL.mkv

Second of all:

Since I extract my TV files in the enclosing folder I would like to know how I can remove the made DIRS (is there any easy script for that?) (My unrarall script only removes most of the file but not dirs)
Cause now with these rules I will always have ~/Downloads_folder/sorted_folder/TV/Noodle.Soft.S01E01.720p.HDTV.X264-HAZEL/Noodle.Soft.S01E01.720p.HDTV.X264-HAZEL.nfo and that's kinda annoying.

Third of all:

is it possible to put a crontab on hazel so it would only run when there is activity in the ~/Downloads_folder/sorted_folder/

Fourth of all:

How can I apply the same movie rule for movies starting with a DIGIT

So there you go, I hope this made sence to all the Hazel users out there and hope I could get some answers on my questions
xieem
 
Posts: 6
Joined: Sat Jan 26, 2013 9:21 am

Re: Moving Folders with Hazel Mon May 11, 2015 11:12 am • by Mr_Noodle
This is a bit much to digest at once but here goes:

I'm not clear on why you are using the script to unrar. Hazel's Unarchive action does throw away the original rars. Also, not sure if this was your intent, but your script is acting on folders, not the rar files. If you insist on using the script, then you need to handle the $1 argument, which is the file/folder being processed. As you have it now, it is hardcoded to one directory regardless of which folder is being matched.

To sort by the first letter, have your rule match that first letter using a custom attribute for it:

Name matches (• first letter)(• rest of name)

where (• first letter) is composed of just a single letter (or digit) and (• rest of name) is (anything). You can then use (•first letter) in the sort into subfolder action.

crontab is not needed. Hazel is much more efficient than that, using fsevents to respond to file events.
Mr_Noodle
Site Admin
 
Posts: 11865
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Moving Folders with Hazel Mon May 11, 2015 7:30 pm • by xieem
Hi,

Indeed your solution makes more sense, I used the unrar script cause it removes *.jpg, empty folders etc. hence the implementation.

What about the moving of a dir instead of a file? Feel like I am running against a wall there.

Thanks for replying
xieem
 
Posts: 6
Joined: Sat Jan 26, 2013 9:21 am

Re: Moving Folders with Hazel Wed May 13, 2015 11:18 am • by Mr_Noodle
Which directory? Hazel's rules work on folders just as they do files.
Mr_Noodle
Site Admin
 
Posts: 11865
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Moving Folders with Hazel Tue May 19, 2015 6:22 pm • by xieem
What I mean is that.

If the folders are extracted I have for example Mr.Noodlesoft.720p.X264-HAZEL/Mr.Noodlesoft.720p.X264-HAZEL.mkv but when I execute the script it's moving Mr.Noodlesoft.720p.X264-HAZEL.mkv instead of the whole dir with the mkv file in it (Mr.Noodlesoft.720p.X264-HAZEL)

Any idea how to fix?

Thanks in advance
xieem
 
Posts: 6
Joined: Sat Jan 26, 2013 9:21 am

Re: Moving Folders with Hazel Wed May 20, 2015 10:58 am • by Mr_Noodle
In that case, you need the rule to match the folder and not the file. If you need to match a folder based on its contents, hold down the option key while clicking the button to create a condition. That will create a nested condition. There, you will see an extra popup for the target. There, you can set that to any/all subfiles. Now, conditions under that nested condition will apply to the files inside the folder but the rule overall matches (and acts on) the folder itself.
Mr_Noodle
Site Admin
 
Posts: 11865
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Moving Folders with Hazel Sun May 31, 2015 2:41 pm • by xieem
@mr_noodle thanks!
xieem
 
Posts: 6
Joined: Sat Jan 26, 2013 9:21 am


Return to Support