Need help making a dynamic tag based on portion of filepath

Hello! I’m new to Hazel and having a really hard time with a tagging rule.

I’m trying to add tags to files within a folder based on the name of that folder. My problem is that I want to use the name of a folder higher up in the filepath as the tag. Ideally, the rule would watch a top folder and apply itself to subfolders. I’d rather have a rule applied this way and not have to hard code a tag for every folder, but I’m not sure what to do. Would this need AppleScript or Keyboard Maestro to work?

Sample idea shown below.

Top Folder (Projects)
ideally the rule would watch this folder

Project 1 (Birthday Party)
Project 1 Subfolder 1 (Invitations)
Project 1 Subfolder 2 (Decoration Ideas)
Every file in all of these folders would be tagged “birthday party”
Currently the files in subfolder 1 are named “invitations” and the files in subfolder 2 are named “decoration ideas”

Project 2 (Vacation)
Project 2 Subfolder 2 (Tickets)
Project 2 Subfolder 2 (Hotel Reservation)
Every file in all of these folders would be tagged “vacation”
Currently the files in subfolder 1 are named “tickets” and the files in subfolder 2 are named “hotel reservation”

1 Like

Maybe this topic will help you.
https://www.noodlesoft.com/forums/viewtopic.php?f=2&t=14950&p=38597&hilit=sub+folder+rename#p38597