Mac GeekeryGet your geek on. |
|
blog advertising is good for you
recent popular content
User login
|
rexroof asks: QuestionHow do a figure out if a file has a color label on it (and what it is) in a perl script? Any applescript or shell program to do it would be awesome. AnswerI’m not really sure if there’s a perly way to do this. I don’t see anything in File::Spec::Mac or Mac::Files that appears to handle reading or changing labels. It can be done with AppleScript, though. Try this little snippet. As is, it only works with files, not folders, but a little digging in the Finder’s dictionary should make it obvious how to use this with other filetypes.
About JC
Author Biography JC is a former Mac Genius and Mac-centric IT worker with a background in print advertising. He earned a reputation as a miracle worker when he saved the day at a new business pitch with the arcane knowledge that Apple’s ADB cables were nothing more than poorly shielded S-Video cables. JC runs the Heroic Efforts Data Recovery Service and writes Ungenius, a tawdry tale of the life and times of a former Mac Genius. You can contact JC via IM or via the contact form. |
perhaps when appscript is ported to perl, this will half to do.
why would appscript need to be ported to perl if Mac::Glue already exists?
If perl can run Unix commands, you can get the kMDItemFSLabel attribute with mdls. Note that the Spotlight index is different than the AppleScript index:
Spotlight AS none: 0 0 red: 6 2 orange: 7 1 yellow: 5 3 green: 2 6 blue: 4 4 purple: 3 5 grey: 1 7