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

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
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