Search code examples
macosapplescriptfinder

Access Finder Tags with Applescript


I'm not looking for too much help today just a simple command, I already have the bare bones to what I need. So Really simple question I am writing an AppleScript that sets my wallpaper based on the Finder Image Tag. Just want to know how do you access Finders Tags in Applescript ... I only can find Finder Labels ??? I have the logic worked out, I just need the method or function or command responsible for obtaining Finder Tags as highlighted in the image below.

Please and thank-you :)

Apple Finder Tags


Solution

  • The new tags aren’t directly supported in AppleScript yet. You have to read them and set them via shell scripting, which you can access from AppleScript with the “do shell script” command. The shell command that you want is “xattr” which enables you to manipulate file metadata on an OS X system. You can type “man xattr” into the Terminal application to get the xattr manual.

    There is also a 3rd party tool called “tag” which may be helpful, because xattr is fairly complicated:

    Tag — A command line tool to manipulate tags on Mavericks files, and to query for files with those tags.

    http://brewformulas.org/Tag