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.
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.
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?
I could use the approach described here (with minor adaptations): http://veritrope.com/code/get-a-list-of-tags-osx/
Again, many thanks for everybody who contributed solutions and ideas here. Very much appreciated.