Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ianthekirkland/2404243 to your computer and use it in GitHub Desktop.
Save ianthekirkland/2404243 to your computer and use it in GitHub Desktop.
Apply color labels to selected Finder items; Ideal for assigning to hotkeys via a Launcher app such as "Keyboard Maestro", "Butler", or "Alfred".
-- Finder-ApplyColorLabelToSelectedItems
-- ©2011 Ian Kirkland, M.Ed, Kirkland Professional Studios
(*
I like to use Finder labels in conjunction with smart folders that point to files and/or folders of a specific label color. That way, I can use red labels for "urgent" to-do items, orange labels for "standard to-do", etc. This script allows a much quicker way of applying color labels.
LEGEND
-------------------------------------------------
Keystroke | Appearance | Label Index
-------------------------------------------------
key "0" = No color = 0
key "1" = Orange = 1
key "2" = Red = 2
key "3" = Yellow = 3
key "4" = Blue = 4
key "5" = Purple = 5
key "6" = Green = 6
key "7" = Grey = 7
• Keystroke: This denotes the number key I assign to each color. You may prefer to do it differently, but the order of colors in the rainbow is pretty hard to forget. like to assign hotkeys such as [ cmd + alt + <number> ]. But, again, do it however you want to.
• Appearance: The color label you'll end up with.
• Label Index: The scripts way of referring to a given label.
*)
tell application "Finder"
activate
set selected to selection
-- apply green label (label index 6 as shown in legend above)
-- to use a different color simply substitute the "6" shown below with the label Index number of the color you want
set myColor to 6
repeat with n_file in every item in selected
set label index of n_file to myColor
end repeat
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment