Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Set Finder color labels via Butler and AppleScript Desktop
I'm one of those "keep my hand on the keyboard at all times" sort of guys. So I was annoyed recently when I discovered that there was no keyboard shortcut to set an item's color label in the Finder. While I don't always use the Finder's color labels, I often find them invaluable when working on projects with complex file and folder structures, indicating which files are "done" and which files are "pending." Using Butler's outstanding ability to execute any AppleScript code via a key combination, I set up the following script:
tell application "Finder"
  set thisItem to selection as alias
  if label index of thisItem = 0 then
    set the label index of thisItem to 2 -- 2 = red
  else
    set label index of thisItem to 0 -- 0 = no label
  end if
end tell
I then set it to run with the arbitrary key-combination of Option-Command-Control-L. This code will toggle on and off the Red label only. However, using Butler and modifying the AppleScript, one could set a combo to toggle all the different labels on and off -- perhaps using one to six on your keyboard, with appropriate modifier keys.
    •    
  • Currently 2.83 / 5
  You rated: 3 / 5 (6 votes cast)
 
[19,434 views]  

Set Finder color labels via Butler and AppleScript | 9 comments | Create New Account
Click here to return to the 'Set Finder color labels via Butler and AppleScript' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Set Finder color labels via Butler and AppleScript
Authored by: jporten on Jun 07, '07 10:11:49AM

I frequently use labels to mark files after they've been post-processed by an AppleScript. For example, I use a script "Comment selected file" which stores text in the Spotlight comments, then changes the label to yellow as a visual cue that a comment exists in Get Info.

Another use for labels -- gray is good for preventing a filename on the desktop from being obscured by the background.

I hadn't noticed until this hint was posted that there's no way to add a keyboard equivalent to labeling in Finder. It's accessible via a control-click or in the File menu, but there's no keyboard access to the color fields, even with arrow keys.



[ Reply to This | # ]
Butler item for changing labels
Authored by: bonobo on Sep 21, '07 04:51:22PM
Thanks to you friendly folks who provided me with the Applescript stuff I was able to put together a small butleritems file which allows me to apply labels (and remove them) via keyboard shortcuts -- and even use a popup menu with colors :-)

Here it is for you, http://www.bonobo.com/media/Finder_Labels.butleritems.zip ... just double-click it to load it into Butler; there's no documentation, so you'll have to look up the keyboard commands in Butler's configuration window.

Enjoy, pass it on.

Cheers, Tom

Cheers, Tom

[ Reply to This | # ]
Set Finder color labels via Butler and AppleScript
Authored by: procton on Jun 10, '07 03:00:01AM

Although quite a few of you probably already know this, it is easily solved with quicksilver. Select item in finder->launch QS->label->red->Enter. QS can be configured to perform this sequence when hitting a short-cut, thus no real need for applescript. What it would not do, however, is toggling. I found no way to do that with quicksilver.



[ Reply to This | # ]
Set Finder color labels via Butler and AppleScript
Authored by: JMacMan on Jun 10, '07 09:26:30PM
There's a similar Applescript from a post at http://forums.macosxhints.com/showthread.php?t=57823. I modified it a bit to prompt for a color on run, but otherwise, this idea works great with Quicksilver. i've been using it for some time now (though I never knew about the built in feature, thanks for pointing that out procton).

[ Reply to This | # ]
Set Finder color labels via Butler and AppleScript
Authored by: bonobo on Jun 11, '07 03:38:57AM

Would you please be so kind to post your modified script? I'd be very glad to have such a choice.

TIA, Tom



[ Reply to This | # ]
Set Finder color labels via Butler and AppleScript
Authored by: JMacMan on Jun 11, '07 09:17:13AM

property defaultColor : "Red"

-- No color = 0
-- Orange = 1
-- Red = 2
-- Yellow = 3
-- Blue = 4
-- Purple = 5
-- Green = 6
-- Gray = 7
set theColors to {"No color", "Orange", "Red", "Yellow", "Blue", "Purple", "Green", "Gray"}

set userColor to choose from list theColors with title "Which color?" with prompt "Please select a color for the selected Finder items:" default items {defaultColor}
repeat with n from 1 to (count theColors)
	if ((item n of theColors) as string) is equal to (userColor as string) then
		set file_color to n - 1
	end if
end repeat

tell application "Finder"
	activate
	set selected to selection
	repeat with n_file in every item in selected
		set label index of n_file to file_color
	end repeat
end tell
would be nice to have colors for each entry rather than just text but I don't think theres any way to do this with Applescript

[ Reply to This | # ]
Set Finder color labels via Butler and AppleScript
Authored by: bonobo on Sep 21, '07 04:44:54PM

Thank you :-)



[ Reply to This | # ]
Butler item for changing labels
Authored by: bonobo on Sep 21, '07 04:56:07PM
Please forgive the double post ... I accidentally wrote the following as a reply to another post here but wanted this to be visible on the first level so nobody misses what I believe could be helpful for all Butler users who also use labels in the Finder.
______________________________________________________

Thanks to you friendly folks who provided me with the Applescript stuff I was able to put together a small butleritems file which allows me to apply labels (and remove them) via keyboard shortcuts -- and even use a popup menu with colors :-)

Here it is for you, http://www.bonobo.com/media/Finder_Labels.butleritems.zip ... just double-click it to load it into Butler; there's no documentation, so you'll have to look up the keyboard commands in Butler's configuration window.

Enjoy, pass it on.

Cheers, Tom

[ Reply to This | # ]
Yet another way to set Finder color labels via Butler and AppleScript
Authored by: octanefilms on Oct 04, '08 07:05:02PM
Combining the Applescript on this MacOsXHints.com page:
http://forums.macosxhints.com/showthread.php?t=57823

with Butler provides the ability to recursively label a group of selected files or just one. Nice!

The following AppleScript code can be pasted into Butler:
-- 0=none, 2=red, 1=orange, 3=yellow, 6=green, 4=blue, 5=purple, 7=grey. Change the number in the 'property file_color' field to match your color needs.

property file_color : 0 --none

tell application "Finder"
activate
set selected to selection
repeat with n_file in every item in selected
set label index of n_file to file_color
end repeat
end tell

or download the Butler container prebuilt here:
http://www.octanefilms.com/butler_finder_labels/Butler_Finder_Labels.zip

Command-Option-L provides a nice pop-up GUI window to choose your label color from a list. Or you can use direct hot keys:
Command-Option-X None Label
Command-Option-1 Red Label
Command-Option-2 Orange Label
Command-Option-3 Yellow Label
Command-Option-4 Green Label
Command-Option-5 Blue Label
Command-Option-6 Purple Label
Command-Option-7 Grey Label

Or you can change the hot keys to suit your needs.

Enjoy.

[ Reply to This | # ]