Read native Finder Tags in Apple Script

I have a rule in hazel that looks for certain files. On the matched files I run an Apple Script that does certain things. Now, I would also like to use the native Finder Tags of the matched files as a variable in that script. Despite extensive Googling, I was unable to find a way to read out the tags within an Apple Script. Does anybody here have an idea how I could do this? An help would be much appreciated.

There looks to be some code listed on MacScripter that if you save it to a script library should provide you with a returnTagsFor method that, if I’m reading it right, should do what you want.

If you haven’t tried it, it looks like it might be worth doing so.

Many thanks for your quick response. Unfortunately I am not able to make this work. I can not create a script bundle from the code provided at Macscripter. Any further ideas maybe or any help with this?

Try the tag command line tool.

1 Like

You really shouldn’t need to unless you are placing that code into a Script Library. Otherwise, you can just paste the handlers you need (which, judging by your initial post, would just be returnTagsFor) and the use framework "Foundation" line into the AppleScript you are running in Hazel and call it directly.

Many Thanks everybody. I was able to figure this out.

Just to wrap up the thread for anyone else who finds it, what does your solution look like now?

1 Like

I could use the approach described here (with minor adaptations):

Again, many thanks for everybody who contributed solutions and ideas here. Very much appreciated.

1 Like