• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 4. The User Interface > Using AppleScript in Contextual Menus

Hack 46. Using AppleScript in Contextual Menus

Ranchero's BigCat is a plug-in to Mac OS X, allowing you to run AppleScripts via a new Scripts item in your contextual menus.

Back in the old days, there was a magical little utility called FinderPop (http://www.finderpop.com/). FinderPop was pre-OS X, and many users saw that it was good . . . very good, in fact. Along with a healthy dose of other features, you could add a number of new abilities to your contextual menu, including the abilities to browse compressed archives, change file types, run AppleScripts, and more. FinderPop, sadly, won't ever exist for OS X, but what else do we have?

Enter BigCat from Ranchero Software (http://www.ranchero.com/). With one simple 185K free download (read that again, eh? 185K!), you can install a plug-in for OS X that will allow you to run AppleScripts via a new Scripts item in your contextual menus.

True to its purpose, BigCat operates on context. When you install the BigCat scripts, there are two subfolders: one for Text, which includes such basic examples as Copy, Google Search, and Open Selection in BBEdit, and the other called Files, containing Copy Path, Open in TextEdit, and Stuff (i.e., Archive with Stuffit). Even though there are two folders, you'll see only one based on — you guessed it — context. Got some text highlighted? You'll see only the scripts in the Text folder will be shown. Selected a bunch of files? Only those in the Files folder.

This is an important advantage over other utilities like ScriptMenu, now shipped by default with Jaguar. Sure, you can run AppleScripts on the current selection via ScriptMenu, but you'll also see all the scripts that have no effect on the current selection (Current Date and Time, etc.). BigCat makes hitting the right script a lot easier.

And what about changing file types and creators [Hack #6]? For a pure AppleScript solution, changing a file's info to that of a common GIF is done like this:

tell application "Finder"
  set filelist to selection as list
end tell

tell application "Finder"
  repeat with i in filelist
    set file type of i to "GIFf"
    set creator type of i to "ogle"
  end repeat
end tell

Or, if you wanted to run a shell script, you could wrap it in an AppleScript as well. Here's the same script as before, only using the utilities provided with the Developer Tools CD:

tell application "Finder"
  set filelist to selection as list
end tell

tell application "Finder"
  repeat with i in filelist
    set macFilePath to (i as alias)
    set unixFilePath to POSIX path of macFilePath
    set command to "/Developer/Tools/SetFile -c ogle -t GIFf " & RETURN
    unixFilePath
    do shell script command
  end repeat
end tell

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint