I want to include in a script a check for a file input to see if the file/folder has a color set and if it does, which one... (I don't need help with the creation of this script, just need the command to check what color the label is).
eg, like these colors (grey): http://img.skitch.com/20090923-t1xsphn47tdq64b8ksb43wh3e8.png
I would like to avoid using apple script.
Using xattr... for instance, I have a directory named "Foo", and I made its label red in the Finder. Then I did:
wilPureSex% xattr -p com.apple.FinderInfo Foo
00 00 00 00 00 00 00 00 00 0C 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Then I made it blue, and you can see the relevant byte change:
wilPureSex% xattr -p com.apple.FinderInfo Foo
00 00 00 00 00 00 00 00 00 08 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
-Wil
mdls -name kMDItemFSLabel -raw "[filename or directory]"
... will output the number of the label. assign it to a variable like this:
LABEL_NUMBER=$(mdls -name kMDItemFSLabel -raw "[filename or directory]")
echo $LABEL_NUMBER
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With