Trying to move some of my scripts over from labels to tags under Mavericks, but I can't seem to find a way to set/add tags with Applescript.
Anybody that know how to do this? As far as I can figure tags aren't actually new, just new in terms of being a more central part of the updated Finder.
Best Answer
You can use xattr. This copies the tags from file1 to file2:
The tags are stored in a property list as a single array of strings:
The tags for colors have values like
Red\n6
(where\n
is a linefeed).If the kColor flag in com.apple.FinderInfo is unset, Finder doesn't show the circles for colors next to files. If the kColor flag is set to orange and the file has the red tag, Finder shows both red and orange circles. You can set the kColor flag with AppleScript:
'("Red\n6","new tag")'
is old-style plist syntax for this:xattr -p com.apple.FinderInfo file|head -n1|cut -c28-29
prints the value of the bits used for the kColor flag. Red is C, orange is E, yellow is A, green is 4, blue is 8, magenta is 6, and gray is 2. (The flag that would add 1 to the values is not used in OS X.)