Can hazel use a unique part of a folder name as a tag for al

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

Moderator: Mr_Noodle

Hey!

Firstly, holy crap Hazel have probobly saved me days of my life! Thanks!

Secondly, I’m working on a system for project file management.

My project folder looks like this

A
A1
A2
A2.txt
B
B1
B1.txt

The first rule I’ve got hazel to run is to rename any new folder that is put into this projects folder with a new project number that is generated by hazel. Like this:

(PE0433) - A
A1
A2
A2.txt
(PE0434) - B
B1
B1.txt

What I’m trying to do now, but having problems with is applying a tag on all documents that are put in any of the folders or subfolders.

So any file that is put in the folder “(PE0433) - A” would automatically get the tag (PE0433). For example, the text file “A2.txt” from the second example would get the tag (PE0433).

I don’t have any problems applying other tags to the subfolder, the problem is specifically:

Is there a way to capture the project number(PEXXXX) from the main project folder and add it as a tag?

/David
Legal90
 
Posts: 2
Joined: Wed Aug 29, 2018 11:31 am

I assume you have a rule to tell Hazel to go into subfolders? If not, then look up "subfolders" in the manual.

Now, one way to do this is to use a nested condition (look it up if you don't know about them yet). With that and match patterns (again, check the manual if this is new to you), you should be able to do something like:
Code: Select all
    If (all) are met
        If (all) are met for (the enclosing folder)
            Name matches (•prefix)(anything)
    Do
        Add tag (•some dynamic tag using •prefix above)

You can have prefix match text inside parentheses if that is indeed the pattern. For the add tag part, you can use a dynamic tag composed of other attributes, in this case, the prefix attribute you created in the condition. Try that out and report back if you run into any issues.
Mr_Noodle
Site Admin
 
Posts: 11193
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Yes!

I had a problem defining my pattern, but i solved it just before bed yesturday. Just as you described it.

Thanks a lot! :)
Legal90
 
Posts: 2
Joined: Wed Aug 29, 2018 11:31 am


Return to Support