I made this script to return the index of the file or folder label as an integer, where:
0 = no colour 1 = orange 2 = red 3 = yellow 4 = blue 5 = purple 6 = green 7 = grey
All you have to do is:
#! getlabel() { osascript - " $@ " << EOF on run argv tell application "Finder" set theArg to POSIX file ((do shell script "pwd") & "/" & argv) as alias set labelIndex to (get label index of theArg) do shell script("echo " & labelIndex) end tell end run EOF }
So now you can do things like:
#! if [ `~/bin/getlabel $1` == 2 ]; then echo yup else echo nope fi
source share