Understanding Enclosing/Any/All/File or Sub Folder menu.

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

Moderator: Mr_Noodle

Good evening,

My problem is this:

I have a large file structure on an ext HD which is full of jpgs. The file structure has varying sub folder depths. Here is an example list of file paths:


Code: Select all
Volumes/LaCie250GB/_ *untitled folder/2693386667_b.jpg
Volumes/LaCie250GB/_ *untitled folder/63abd75018_b.jpg
Volumes/LaCie250GB/_ *untitled folder/b9f99a2009_a.jpg
Volumes/LaCie250GB/*Untitled_Folder/img_B-TEC_01.jpg
Volumes/LaCie250GB/*Untitled_Folder/img_B-TEC_02.jpg
Volumes/LaCie250GB/*Untitled_Folder/img_B-TEC_03.jpg
Volumes/LaCie250GB/B-TEC_001/DSC0001.jpg
Volumes/LaCie250GB/B-TEC_001/DSC0002.jpg
Volumes/LaCie250GB/B-TEC_001/DSC0003.jpg
Volumes/LaCie250GB/Unsorted/to-sort/New Folder_01/01_B-TEC.jpg
Volumes/LaCie250GB/Unsorted/to-sort/New Folder_01/02_B-TEC.jpg
Volumes/LaCie250GB/Unsorted/to-sort/New Folder_01/03_B-TEC.jpg
Volumes/LaCie250GB/Unsorted/to-sort/New Folder_02/1.jpg
Volumes/LaCie250GB/Unsorted/to-sort/New Folder_02/2.jpg
Volumes/LaCie250GB/Unsorted/to-sort/New Folder_02/3.jpg
Volumes/LaCie250GB/Year_1/B-TEC-001.jpg
Volumes/LaCie250GB/Year_1/B-TEC-002.jpg
Volumes/LaCie250GB/Year_1/B-TEC-003.jpg



The HD holds around 15GBs of images and has varying sub-folder depths, the maximum being around 7, however most are at sub-folder depth 2 - LaCie250GB/Folder/Image.jpg

As you can see, some of the jpgs have the word "B-TEC" in the file name while some have the word "B-TEC" appearing somewhere in the file path, but not necessarily in the file name, which may be a hash instead. Some folders do not contain relevant images and do not have "B-TEC" in either in the file name or path.

I need to be able to look at the and HD and see where the B-TEC pictures are WITHOUT CHANGING THE FILE STRUCTURE OR MOVING FOLDERS AND FILES. The best way to do this is to simply colour code the folders which eventually contain a jpg with "B-TEC" in the name, or have the word "B-TEC" somewhere in the file path.

This means setting up a rule will look at each file path, see if the word "B-TEC" is contained somewhere within it, and set a colour label to the highest level folder in the file path if there is, or the entire file path if possible. In the example file paths above they would be:

Code: Select all
Volumes/LaCie250GB/*Untitled_Folder/img_B-TEC_01.jpg
Volumes/LaCie250GB/B-TEC_001/DSC0001.jpg
Volumes/LaCie250GB/Unsorted/to-sort/New Folder_01/01_B-TEC.jpg
Volumes/LaCie250GB/Year_1/B-TEC-001.jpg


- et al...

So far I can easily set colours to FILES which have "B-TEC" in their filename using the standard Sub Folder Rule

Code: Select all
IF KIND > IS > FOLDER - then - RUN RULES ON FOLDER CONTENTS
then
IF NAME > CONTAINS > B-TEC - then - SET COLOR TO > BLUE


Standard stuff...


However the problems start when I try and set colours further back up the file path. I've been dicking around with the Enclosing/All/Any/Sub/Files or Folders drop down menu but with only limited success as I've not been able to set a colour to any folder higher than the the folder immediately above another file or folder which contains the word "B-TEC".

I currently have the following rules:

RULE 1 - Sub Folder Rule

Code: Select all
If ALL of the following conditions are met for ANY OF ITS SUB-FILES OR FOLDERS
KIND > IS > FOLDER
Do the following to the matched file or folder:
RUN RULES ON FOLDER CONTENTS


RULE 2 - Colour Folders in File Path That Contains B-TEC Reference

Code: Select all
If ALL of the following conditions are met for ANY OF ITS SUB-FILES OR FOLDERS
NAME > CONTAINS > B-TEC
Do the following to the matched file or folder:
SET COLOR TO LABEL > BLUE


One thing I don't understand is why the Sub Folder Rule above needs to be be set to "ANY OF ITS SUB-FILES OR FOLDERS" in order to work.

Any ideas on how to do this? I really have tried looking for the answer here in the Hazel forums and in the wider Google-sphere, but most searches only give me instructions about the standard sub folder rule...

How do you write a rule to descend into sub-folders, but then act on folder back up at the top.

Also is there a good tutorial on how the "Enclosing/All/Any/Sub/Files or Folders" drop down menu actually works and how it behaves when "Running Rules On Folder Content"...?

Hope this isn't too much of a brain warp...

Many thanks in advance...
PigeonCake
 
Posts: 8
Joined: Thu Jan 21, 2010 8:13 pm

I'm currently fiddling about with the 'file pathname' tag which is helping me find my search term, but still unsure how to set a colour for the the top level of that path...
PigeonCake
 
Posts: 8
Joined: Thu Jan 21, 2010 8:13 pm

If you want to color the top level folder only, you don't need to go into subfolders. Try it with just rule #2.
Mr_Noodle
Site Admin
 
Posts: 11865
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Ah. Thanks. That colours the top folder Blue. Obvious really. I think I was over thinking it, I think.

I'm going to see if I can get it to colour the whole file path right down to the file... If I can't I might be back in a bit...
PigeonCake
 
Posts: 8
Joined: Thu Jan 21, 2010 8:13 pm

Well I kind of achieved it. You were right about just running rule 2 to highlight the top level folder. That's obvious with an understanding of how that menu works.

One thing I didn't figure out though, and I'm not sure if it's even possible, is how to how to get Hazel to colour the entire file path recursively UP from a certain file to the top level folder being watched.

Any ideas...?

Is that even possible...?
PigeonCake
 
Posts: 8
Joined: Thu Jan 21, 2010 8:13 pm

Odd request but there are a couple ways to do it. I think the two rules that the original poster had would do what you want though it will be slow as heck.

An alternative will be to use the subfolders rule, and then use an AppleScript to re-target the rule to the parent folder, then color the folder. Here's an article on how to do the re-targeting: viewtopic.php?p=1545#p1545
Mr_Noodle
Site Admin
 
Posts: 11865
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Ahhh. That's Brilliant. That's very useful. I was wondering if it possible to do this but alas I'm not much of a coder, even with Apple Script..

Much experimentation coming up...

Regards...
PigeonCake
 
Posts: 8
Joined: Thu Jan 21, 2010 8:13 pm


Return to Support