Page 1 of 1

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

PostPosted: Wed Aug 29, 2018 11:39 am
by Legal90
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

Re: Can hazel use a unique part of a folder name as a tag fo

PostPosted: Wed Aug 29, 2018 11:57 am
by Mr_Noodle
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.

Re: Can hazel use a unique part of a folder name as a tag fo

PostPosted: Thu Aug 30, 2018 3:50 am
by Legal90
Yes!

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

Thanks a lot! :)