Writing Big Cat Scripts

Where scripts are stored

Scripts are stored in the ~/Library/Application Support/Big Cat Scripts/ folder. There are two sub-folders.

The Files folder is for scripts that appear when you have selected one or more files or folders.

The Text folder is for scripts that appear when you have selected text in an application that supports contextual menus.

Writing AppleScript scripts

Every AppleScript script contains a subroutine named main. It takes one parameter.

For text scripts the parameter is the selected text. For files scripts the parameter is the list of selected files.

A simple AppleScript that just echoes back your selected text looks like this:

on main (s)
     display dialog s
end main

For files scripts the parameter is the list of selected files. A simple script which just displays the paths of selected files looks like this:

on main (filelist)
   repeat with oneFile in filelist
      display dialog (oneFile as string)
   end repeat
end main

Most of the examples that come with Big Cat are AppleScript scripts.

AppleScript scripts should be saved on disk as compiled scripts.

Writing shell scripts

As with AppleScript scripts, shell scripts take a parameter—either the selected text or the selected files.

A simple shell script that just echoes back the parameters looks like this:

#!/bin/sh
echo $*

See the Touch example script (in the Files folder) to see how to loop through a list of files.

Shell scripts must be marked as executable. You can do this via the command line: chmod u+x myScript—where myScript is the path to the script.

(What that command does is say that the user “u” is allowed to execute “x” the script.)

Shell scripts should be saved on disk as plain text files.

© Copyright 2005-2008 NewsGator Technologies, Inc.


NetNewsWire: More news, less junk. Faster