is there a command line utility for changing the color label of files in macosx?
Asked
Active
Viewed 1,671 times
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).
Daniel Beck
- 111,893
0
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.
JRobert
- 7,134
0
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
label(){
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"
else
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
EOF
fi
}>