views:

316

answers:

2

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.

+2  A: 

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

Wil Shipley
Oh wow, this is going deep, thanks.But seems to do the trick.Will the color always be shown on that same byte?
Mint
I have no idea, I just started playing with it and this is what I discovered.
Wil Shipley
ok, well it seems to work for now, thanks again.
Mint
A: 

You can also use "mdls filename" and look for the kMDItemFSLabel value. I'm looking for a way to change the label via command line if anyone knows of a way.

Ryan Epperson