Joe Strout's

Handy Applescripts


Applescript, in case you didn't know, is a wonderful scripting language for the Macintosh. With it, you can tie applications together (for example, making a button in a Filemaker Pro personnel record call up that person's home page in Netscape). You can also automate repetitive tasks and make simple applications. (Applescript is included in all recent versions of the MacOS operating system.) Besides this one, there are other Applescript archives on the net. Below are some Applescripts which I've written. Perhaps you'll find them useful or instructive (I try to comment them liberally). If you have any questions or comments, please write to me.

To download the scripts:

  1. view the source, then Select All and Copy
  2. launch the Script Editor
  3. Paste into the Untitled window
  4. Save it as an Application
You may also want to copy the brief description (below) into the description box in the Script Editor window for future reference.
Batch Download
Make BBEdit
Quit Application
Make Mini GIFs
Tree Print


Batch Download

This script uses Netscape to download a batch of URLs, one at a time. The URLs to be downloaded should be listed in a text file, one per line, with no extra spaces or punctuation. This file (or several such) can be dropped onto the application; or just double-click the app, and it will ask for the file. Uses the Speech Manager for feedback.

Customization: If you don't have the Speech Manager, change the "say" commands to "display dialog" or take them out altogether. Change the download folder (currently the desktop) to something else, such as "MegaDisk:Data:Downloads:".


Make BBEdit

This simple script makes files into BBEdit text files (i.e., changes the file type and creator). Drop a bunch of files on the application, and they'll be converted. Better yet, select a set of files in the Finder, and launch this script from the Apple Menu. (Why BBEdit? Well, as they say, it doesn't suck. And you can get BBEdit Lite for free, to boot.)

(I especially like using it the latter way, as it effectively adds to the set of Finder commands. But it means that you can't usefully launch the script by double-clicking it.)

Customization: A good improvement would be to have the script check the file type, and only change certain ones (maybe "TEXT" and "????"), to prevent inadvertently breaking applications and such.


Quit Application

When I installed the Speech Recognition software, I noticed that although it included scripts to close a window (or all windows), it did not include a voice command for quitting the current application. So here it is!

This is a very simple app which quits the frontmost application. It includes some error checking and speech feedback. Save this as an application (with "Never show startup screen" checked) in the Speakable Items folder.

Customization: A variation of this script could be made which would quit all applications. You could call it something like "Quit All Applications".


Make Mini-GIFs

Here's a simple script that takes a bunch of graphics files and makes miniature GIF versions of them. Drop a batch of files on the script, or select them in the Finder and launch this script via the Apple Menu. If the original file is named mypic.jpg, the output of this script is named mypic-mini.gif.

Note: This script requires clip2gif, a great freeware utility by Yves Piguet.

Customization: This script could be expanded to build an HTML page from the set of selected pictures, so that the miniatures would link to the full-sized version of each picture.


Tree Print

This script lists generates a hierarchical listing of all files under a given folder or disk. It is meant as a demonstration of traversing a directory tree; you could replace the "listing" behavior with any operation you want to perform on a set of nested files and folders. Scriptable Text Editor is required for this example.


http://www.strout.net/info/coding/applescript/index.html
Last Updated: 11/19/98 . . . . . . webmaster@strout.net