Category Archives: Mac OS X

Set Finder-Labels via Butler

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
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.

Using Butler to Key-Command URL

One of my favorite productivity apps is Butler. While the “Which launcher app is better?” debate will rage interminably, I especially like Butler’s ability to perform web searches simply via a keyboard shortcut activated pop-up bezel interface. All I have do to is hit Command-Option-Control-G, and a bezel box opens, allowing me to perform a Google search no matter what app I’m in. Ditto for -M and Google maps, -V and Version Tracker, etc.

I found myself wanting the ability to assign a simple keyboard shortcut, get a dialog box, and open any URL I wanted — no reaching for my browser. While Butler contains a way to do this, it generally requires a step or two more than I’d like, and I wanted a more direct solution. Using one of Butler’s most powerful features — the ability to execute any AppleScript code with only a keyboard shortcut — I implemented the following code:

display dialog “URL?” default answer “” buttons {“.net”, “.org”, “.com”} default button 3
set {text returned:theURL, button returned:theDomain} to result

if theURL is “” then error number -128 — cancel

if (offset of “.” in theURL) is 0 then
— This works for other domains, as long as no subdomains are entered
set theURL to theURL & theDomain
end if

if theURL starts with “www.” then
set theURL to “http://” & theURL
else if theURL does not start with “http://www.” then
set theURL to “http://www.” & theURL
end if

tell application “Safari”
open location theURL
end tell

(With a little revision from our friends at

I’ve assigned this to the key combination Command-Option-Control-U, and now I can open a URL no matter what application I’m in or what I’m doing — and with almost no attention necessary to the prefix or suffix.