Page 1 of 1

Fun With Subfolders!

PostPosted: Sun Sep 30, 2012 2:04 pm
by TheOneTrueRobb
OK, sit back, this may take a while....

I've got a folder...let's call it, oh, Movie Rips.

Within that folder there some other folders. These folders are put there by a theoretically existing program that we'll call, ummm...MacTheRipper, say.

The folders within this folder are changing constantly, added, deleted, moved, etc., but they all have one thing in common: They contain a folder within them called "VIDEO_TS", with all caps and the underscore, and sometimes some other files and folders that I'm not interested in.

What I want to do is remove all the folders in these folders NOT named VIDEO_TS. As the names of these folders are obviously changing constantly, I want to do this with Hazel's Subfolder mechanism. There's a sticky here on the NS forum that's been a help, but I can't...quite...get it to do what I want yet.

After doing some experimentation, here's where I'm at now:

Rule Name: Set Up Subfolders

If All of the following are met for the File or Folder being matched:

Kind is Folder
Subfolder Depth is less than 1 {more on this in a bit]

Run rules on Folder Contents.

Followed by:

Rule Name: Action

If all...File Or Folder Being Matched

Name is Not VIDEO_TS

Set Color Label to Purple [eventually, this will be Move to Trash]


Under these rules, the only file or folder that actually gets colored Purple is an Alias file, at the top level of the Movie Rips folder.

If, in the Action Rule, I change the first entry to "Name Is VIDEO_TS", it works fine. This is the thing that makes me want to go swallow Drano.

The "Name Is Not" rule also works in a test folder I've been working with, another thing that makes me mournfully eye bridge abutments when I'm driving st high speeds, obsessing about this stuff.

The "Subfolder depth <1 rule" entry in the Set Up Subfolders rule is pretty suspect, but I was trying to get Hazel to stop at a certain level and address folder names, rather than entering the folders. As I said, it works when the rule is written to match the VIDEO_TS name, but not when the rule is to match any thing BUT that name.

Another thing that makes me load up my spare .44 Magnum: the "Name Is NOT VIDEO_TS" rule looks fine when using Hazel's Preview function.

Anyway, thanks for any help anyone can provide. I know Mr. Noodle lives to read through complicated customer issues when he could be out having a "life" of some kind. You readers who really love to hear folks like me complain can PM me, and I'll tell about you how the Lion upgrade messed up my Midi system somethin' awful. Don't get me started...

Oh, and TheOneTrueRobbCo in no way endorses any unlawful copying of DVDs from those scumbags at the hideous and evil NetFlix company. Because that would be just, just...wrong. Right? Don't do it, kids. And stay off drugs...

Re: Fun With Subfolders!

PostPosted: Sun Sep 30, 2012 2:52 pm
by a_freyer
WIthout setting up your rule to test, I think I can see the issues. First, the "Subfolder Depth" component of the rule is not really being used properly. Second, you're asking Hazel to delete folders before it reaches video_ts.

Here is how I would modify your rules:

Rule 1: Dive into Subfolders
Code: Select all
If (all) of the following are met for (the File or Folder being matched):
     Kind is Folder

Do the following to the matched file or folder:
     Run rules on folder contents



Rule 2: Delete Non_TS Folders
Code: Select all
If (all) of the following are met for (the File or Folder being matched):
     Subfolder depth is 2
     Name is not VIDEO_TS

Do the following to the matched file or folder:
     Set color purple


Rule 3: Delete Empties
Code: Select all
If (all) of the following are met for (the File or Folder being matched):
     Size is 0
     Kind is folder

Do the following to the matched file or folder:
     Move to trash

Re: Fun With Subfolders!

PostPosted: Fri Oct 05, 2012 8:21 pm
by TheOneTrueRobb
A_Freyer:

Tried your rules, above. Here's the results:

(I changed "set color to purple" in your second rule set to "move to Trash").

In the VIDEO_TS folders, every file got moved to the trash, except some files that were also named VIDEO_TS, each with different extensions.

Otherwise, no VIDEO_TS folders got moved to the trash.

I've been buggering around with subfolders for a while now, and it seems that Hazel's "run rules on folder contents" function just doesn't work on folders. Seems that every time the rule encounters a folder, it just enters that folder and seeks out files that match the criteria of the post-"run rules on contents" rules, if that makes any sense.

Perhaps I'm missing something. I need Hazel to go down a specified level and then match files AND folders at that level.

I'm not complaining, and wanna thank you for answering with a pretty good suggestion off the top of your head. I couldn't make it work, but that's on me (and Mr. Noodle).

Re: Fun With Subfolders!

PostPosted: Fri Oct 05, 2012 9:07 pm
by a_freyer
Alrighty. I'll check this out tomorrow morning and see what the issue is.

Re: Fun With Subfolders!

PostPosted: Mon Oct 29, 2012 4:11 pm
by TheOneTrueRobb
Just checking in: Anybody have any luck with this?

Re: Fun With Subfolders!

PostPosted: Mon Oct 29, 2012 4:17 pm
by a_freyer
Sorry about not getting back. Is it possible for you to post your rules so I can see what's going on?

Also, can you list out what your exact folder tree is?

Re: Fun With Subfolders!

PostPosted: Wed Oct 31, 2012 11:22 am
by Mr_Noodle
I think TheOneTrueRobb's rules are closer in that it limits how far down to go. I'm guessing you don't want to dig into the folders beyond that first level.

I suggest pausing rules for that folder and solely use the preview. If it doesn't look right there, it's not going to magically work when you run the rules. Make sure it's exactly as you expect. If a file is not matching the way you want, click on the "i" button and look at the fields.

Re: Fun With Subfolders!

PostPosted: Fri Jan 04, 2013 10:19 pm
by TheOneTrueRobb
Mr_Noodle wrote:I think TheOneTrueRobb's rules are closer in that it limits how far down to go. I'm guessing you don't want to dig into the folders beyond that first level.

I suggest pausing rules for that folder and solely use the preview. If it doesn't look right there, it's not going to magically work when you run the rules. Make sure it's exactly as you expect. If a file is not matching the way you want, click on the "i" button and look at the fields.


Oh, well, lookee there, you joined the discussion while my attention was elsewhere. Was that really last October? My apologies...

Yeah, I'm learning to use the Preview function. Haven't quite figured how to use subfolders such that Hazel stops at a certain level and works on both files and folders, though.

Will be giving this a new look over the weekend and will post rules, etc., for your perusal....