Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

is there a command line utility for changing the color label of files in macosx?

share|improve this question
Possible duplicate of superuser.com/questions/168927/… Basically, use AppleScript. –  NReilingh Jan 17 '11 at 18:05

3 Answers 3

You can write it yourself. Open /Applications/Utilities/AppleScript Editor.app and enter the following:

on run argv
    tell application "Finder"
        set theFile to POSIX file (item 1 of argv) as alias
        set labelIdx to (item 2 of argv as number)
        set label index of theFile to labelIdx
    end tell
end run

Save as color.scpt and invoke from Terminal like this:

osascript color.scpt somefile.txt 3

somefile.txt will be colored, 3 is the color: 0 means colorless, 1 through 7 are the Finder's colors (with 1 being red).

share|improve this answer

This article, View and set Labels from the command line, describes a command line utility to do it. Caveat: it's an old article, describing a utility for OS 10.3, and I haven't tried it myself.

share|improve this answer

Based on the responses here and in referenced posts, I made the following function and added it to my ~/.bash_profile file:

# 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

share|improve this answer
Didn't you get the order wrong? Red is before orange, isn't it? –  Daniel Beck Mar 10 '11 at 4:33
@Daniel No, the default order of colors sucks. You could actually edit your answer to take it into account. –  ؘؘؘؘ Mar 10 '11 at 12:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.