Folder Actions System Extension
The Standard Additions scripting addition now includes several commands for use in folder action scripts. When a script containing these commands is attached to a folder, the script will be run automatically whenever the folder’s window is moved, opened or closed, or items are added to it or removed from it while its window is open. In addition, the Folder Actions system extension is itself scriptable, so that scripts can be attached to or removed from a specified folder under script control. Several sample folder action scripts are included in the Folder Action Scripts subfolder of the Scripts folder in the standard Mac OS 8.5 installation. My shareware Folder Action Setup control panel application uses FaceSpan and AppleScript to create a window-based interface for the Folder Actions extension.
Apple’s AppleScript site includes a QuickTime demonstration of folder actions by Sal Soghoian, and its workflow tutorial is based on folder actions. 10/10/99
Andy Bachorski of Apple has explained how folder actions are implemented: There is a modified alias record pointing to the attached script stored in the icon\r file (the \r is a return character). There can be multiple scripts attached to a folder, so there can be multiple alias records. The folder is marked as having an attached alias via a special ‘badge’ bit in one of the Finder information fields. Brett Gross noted that this makes it easy to lose attached folder actions (or at least their links) accidentally: Mac OS 8.5’s folder actions are stored in the resource fork of the invisible icon file for a folder. There are several utilities (none of which come to mind at this moment) that remove custom icons. It is possible for these utilities to remove a folder action by assuming it is a custom icon. Apple has released a Tech Note telling people to leave the invisible icon file alone. 10/10/99
These other Apple and third-party scripts have been released relating to folder actions:
A folder action script to switch Kaleidoscope schemes automatically when opening or closing a specific folder.
Steve Jones wrote CS Loader, two very clever Mac OS 8.5 folder action scripts. When attached to the Control Strip Modules folder in the System Folder, these scripts implement dynamic loading of control strip modules. When modules are dropped into or removed from the folder, they will automatically be enabled or disabled on the fly. Unfortunately, these scripts are run-only, so you cannot examine the code. (I can no longer find them on his web site; try email.) 10/13/99