Don't understand subfolder logic. Need a bit of help.

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

Moderator: Mr_Noodle

I am trying to scan a ./Downloads directory. However I can't seem to figure out how to get Hazel to do anything else. I downloaded the sample rule "Go into subfolders". I would like Hazel to look for a directory with name "foo" and then look for .rar files in directory foo, and finally extract them. I am not understanding how to accomplish this.

These are the events as I understand them in Hazel:
Scan directory "Downloads" for folders with name "foo"
if folder=foo then execute commands in this directory "foo"

This doesn't seem to work in Hazel. The only thing the sample rule is able to do is find folders and nothing else. There are no File Attributes options for "Kind" or "Name" in rules with this sample. This only seems available at the root level.

If I go the other route of trying to look for a folder with a specific name and then try and perform an unarchive command on the folder Hazel will not descend into the folder. I'm really frustrated at how difficult this is to do in Hazel.

What am I missing?
argonaut
 
Posts: 3
Joined: Tue Feb 03, 2015 12:32 am

Is the directory "foo" always at the top level? If not then you probably shouldn't edit the "go into subfolders" rule. Also, keep in mind you want to run the unarchive on the file within, not the folder itself. You need to keep this separation straight or else your logic will be off.

So, you want to unarchive a rar file within a folder named "foo". First off create your rule to unarchive rar files (this should be straightforward). Now, add a condition like:
Code: Select all
    If (all) are met for (the enclosing folder)
        Name is foo

To get that sub-condition, hold down option while clicking the + button to create a new condition. What that condition does is match if the file's parent folder is "foo".

Finally, you want the unedited subfolder rule to tell it to go into subfolders so it can find that rar file in the first place.
Mr_Noodle
Site Admin
 
Posts: 11872
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Thanks for your quick response Mr_Noodle.

The folder foo is not always present. I was being a bit hesitant and not open as I am new to this forum. However, open discussion about torrents seems to be okay here.

This is a torrents download folder. Things come and go and what I was hoping to achieve is rules for managing TV shows such that if a new episode is downloaded I would be able to extract the video file from the multipart rar file and move it to the correct location on disk.

So It appears you are suggesting I run multiple Rules on a folder. I think ... I would execute the "go into subfolders" rule first and then run a second rule to unarchive the rar file. I'm stumped as to how to do that. I couldn't find an example of how to extract a rar file and my attempts have all failed. (I'm not very clever.)

Here is what I have so far:

Image

Image

When I execute "Run Rules Now" it copies the directories in the "Torrents Downloads" directory and all files to a the new directory, but Hazel does not appear to run the second rule (which is probably wrong anyway, but I'm not there yet). I think it is because Hazel is only running the next rule on the "Torrent Downloads" directory and not on tmp. Do I need to need to add a new folder of "tmp" to Hazel and then run rules on that folder or can I continue to run the rules for the "Torrent Downloads" directory on another directory?

p.s. I'm sure someone has already done this with Hazel but I could not find an example anywhere.

Thanks.
argonaut
 
Posts: 3
Joined: Tue Feb 03, 2015 12:32 am

If you copy the directory somewhere else, note that the second rule will apply to the originals. So yes, you should have Hazel monitor that destination directory if you want to do further processing on those.

Also, a couple problems with your second rule:
    * If you want to match against the name and extension at the same time, use "Full Name".
    * Hazel does not do regexes directly. Look at using "matches" instead. Plus, all matches are case-insensitive anyways.

You should also consider using custom attributes instead of hardcoding the name and destination, otherwise you'll end up with a ton of rules. Search the forums as people have come up with different ways of filing TV shows.
Mr_Noodle
Site Admin
 
Posts: 11872
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Hurray I figured out almost every. I just need to write better rules so I don't have a million rules for each TV show. That is phase two. Hopefully my solution will help someone else. Probably not as I am clearly the dumbest person using this software.

Here is what I did:

This is my source directory ruleset:

Image

This is the rule to move any new downloads of Broadchurch:

Image

This is my extraction directory ruleset:

Image

This deletes any prior directories left over from a previous run:

Image

This is the rule to go into subfolders: (it does nothing else)

Image

This is the rule to extract a TV episode: (should work on any TV show)

Image

This rule deletes the .NFO and .SFV file:

Image

And finally this rule copies the .mkv TV show to the correct season directory:

Image
argonaut
 
Posts: 3
Joined: Tue Feb 03, 2015 12:32 am

argonaut thank you for the overview - I too am new to Hazel and I must be extremely slow in learning how to do this - I can't seem to get this to work. I too have downloaded/seeding TV show folders that contain multiple rar files using uTorrent. I continue to get an error when running. My Unarchive folder contents are the result of the Seeding folder copying over any folders containing more than 3 files (the multiple rars folders).

Within the Unarchive folder I've tried several different rules and get the same error "failed to unpack archive". I've even set the rule even for a specific file name (i.e., Bull). Ideally I would like to not specify "Bull" but am very stuck on all of this.

Any help appreciated!!

Setup:
ALL
Full Name contains Bull
Do the following to the matched file or folder:
Unarchive


2017-10-10 09:06:59.252 hazelworker[4472] Processing folder Unarchive (forced)
2017-10-10 09:07:01.264 hazelworker[4472] Bull.2016.S02E01.720p.HDTV.X264-DIMENSION: Rule 2) Extract TV Rar matched.
2017-10-10 09:07:01.277 hazelworker[4472] Could not identify archive type for file: /Users/CLJ/Desktop/Unarchive/Bull.2016.S02E01.720p.HDTV.X264-DIMENSION
2017-10-10 09:07:01.277 hazelworker[4472] [Error] Unarchive failed: Failed to unpack archive for /Users/CLJ/Desktop/Unarchive/Bull.2016.S02E01.720p.HDTV.X264-DIMENSION.
2017-10-10 09:07:01.281 hazelworker[4472] Received abort event.
2017-10-10 09:07:03.291 hazelworker[4472] Received abort event.
2017-10-10 09:07:03.293 hazelworker[4472] Done processing folder Unarchive
Wakeforest02
 
Posts: 3
Joined: Tue Oct 10, 2017 6:24 am

The Unarchive action works on archive files, not folders. You need to set up a rule to match the .rar file and unarchive that.
Mr_Noodle
Site Admin
 
Posts: 11872
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support