Very useful! Thanks so much.
If you have only a handful of tags (as Apple seems to assume we do), then it wouldn’t be so hard to make a separate Hazel rule for each and every tag. But if you have a couple hundred tags, as I do, then that’s not going to work.
So, inspired by “Automators 8: File Automation” I starting thinking whether there might not be more to get out of Hazel. (I’m sure I’m reinventing the wheel here…). I figured there must be a way to break down the syntax of the the “Work” attribute in Hazel (tagit_work, in your example) to have three elements this: “tagit” “abc” “_”, so that the matching is agnostic about the “abc” part. If there were then a way to generate a variable from that string, in each case, and to use that variable as the tag that is used in the “Add tags” action.
Here’s an example: to apply my tag “keyreference”, then I append to the filename this:
I then have a Hazel rule that matches the text after the - and then uses that text (“USETHIS” in the screenshot) to add a tag. I’ve also added a tag “tagconversion”, just so I can troubleshoot cases where it doesn’t work properly. I’m attaching a screenshot. Hope this is clear! It’s certainly helping me out.