10/19/12 22:02:00

Update: Set Color Labels from Alfred and Terminal

EDIT: As far as I’m aware, the provided Alfred Extension does not work in Alfred 2!

I’ve updated the Set Finder Labels via Terminal and Alfred post as per two suggestions.

This one shortens the Terminal bit quite a bit. Thanks Lauri Ranta! Much appreciate the contribution. His version doesn’t allow to use “orange” (the typed out word) to set the label though. Here’s a merged version.

# Set Finder label color
  if [ $# -lt 2 ]; then
    echo "USAGE: label [0-7] file1 [file2] ..."
    echo "Sets the Finder label (color) for files"
    echo "Default colors:"
    echo " 0  No color"
    echo " 1  Orange"
    echo " 2  Red"
    echo " 3  Yellow"
    echo " 4  Blue"
    echo " 5  Purple"
    echo " 6  Green"
    echo " 7  Gray"
    osascript - "$@" << EOF
    on run argv
        set labelIndex to (item 1 of argv as number)
        repeat with i from 2 to (count of argv)
          tell application "Finder"
              set theFile to POSIX file (item i of argv) as alias
              set label index of theFile to labelIndex
          end tell
        end repeat
    end run

Second, my Extensions had my test path still in them. I overlooked it and just now found out about it by going through the comments (which I do occasionally only). Reader Thieme Hennis provided a script that takes the Finder selection as input. Thanks, Thieme!
I’ve updated the extensions.