Folder Actions

A folder action is a script that the Mac triggers automatically whenever you do something specific to a particular folder: open it, close it, move it, resize it, or change its contents.

Attaching and Removing Folder Actions

If you’ve never before used folder actions, first run the Enable Folder Actions script from the Script menu, which turns on the feature. (You can also turn on Enable Folder Actions in the new Folder Actions Setup program, which is in your Applications AppleScript folder.)

Then, to attach a script to a folder, see Figure 7-6.

Tip

A folder shows no indication that an action is attached. You can, however, add a little indicator badge to it manually. The badged icon has vanished from Apple’s AppleScript site, but you can still download it from the “Missing CD” page at http://www.missingmanuals.com .

Keep your eye on http://www.apple.com/applescript/folderactions too, for updated versions of the canned folder action scripts that come with your system, plus extra sample script.

To attach a script to a folder, Control-click the folder’s icon. From the contextual menu, choose Attach a Folder Action. Then, in the dialog box, select the folder action script you want to run whenever somebody interacts with the specified folder. (It’s perfectly OK to attach more than one script to a folder.)

Figure 7-6. To attach a script to a folder, Control-click the folder’s icon. From the contextual menu, choose Attach a Folder Action. Then, in the dialog box, select the folder action script you want to run whenever somebody interacts with the specified folder. (It’s perfectly OK to attach more than one script to a folder.)

To remove a Folder Action script from its folder, use any of ...

Get Mac OS X: The Missing Manual, Panther Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.