- Find an Item
- Create a New Folder
- Rename a Folder or Document
- Make an Alias (Shortcut)
- Change an Icon
- Set a Color Label
- Move, Copy, or Delete a Document or Folder
- Burn a CD/DVD
- Add a Newly Installed Hard Disk to the System
- Partition a Hard Disk
- Set Up Software RAID
- Assign a Folder Action
- Add a Second Display
- Set the Time and Date
- Enable Automatic Time Synchronization (NTP)
Assign a Folder Action
AppleScript, the built-in application-aware programming language included in Mac OS X, can be harnessed to extend the functionality of the Finder. AppleScript gives you the ability to assign folder actions to individual folders in the system. What the script can do is limited only by your imagination.
Key Term - Folder actionA script (a simple human-readable program) that you attach to a folder. Triggered by certain events, such as when you open or close the folder or add an item into it, the folder action script performs some function.
Apple provides a few sample folder action scripts, in the Scripts folder inside the main system Library. These include a script which will display the folder's comments in a dialog box when you open the folder in the Finder (useful for making sure that other users are told some useful piece of information if they wander into the folder); one which pops up a dialog box informing you when any new items are added to the folder; and one that, when you close the folder, closes any windows showing sub-folders of that folder. If you like, you can modify these scripts or use them as examples for new scripts that you write.
Enable Folder Actions
Navigate to the Folder You Want to Configure
Attach a Folder Action
Choose a Script
Test the Folder Action
Edit a Folder Action Script
Configure Folder Actions
Folder actions are controlled from the contextual menu which you open by Control+clicking or right-clicking on or inside any Finder window or the Desktop.
Open the contextual menu; select Enable Folder Actions. This turns on Folder Actions globally and allows you to assign them anywhere in the system.
Open a Finder window and navigate to the folder to which you want to assign an action script. You can set up folder actions either from within the folder in question, or in the folder above it in the hierarchy.
Control+click or right-click the selected folder and select Attach a Folder Action from the contextual menu. A file selector window opens, by default starting in the global Folder Action Scripts folder in /Library/Scripts.
You can choose one of the many sample scripts in this folder or any other script you have written or downloaded. Choose the script file and click Choose to assign the script to the selected folder.
Inside the AppleScript folder in the Applications folder, you'll find another collection of folder action scripts you can attach to folders. Use the built-in navigator to locate these scripts and attach them.
You can assign multiple scripts to the same folder, if you like.
Depending on what the script does, it will be triggered by different actionsadding an item to the folder, opening or closing the folder, and so on. Make sure that the folder reacts properly when you trigger it. For instance, if you selected the open - show comments in dialog.scpt script, first use the Get Info panel to add a comment to the folder. Then open the folder and make sure that a dialog box pops up showing you the comments you entered. In the example shown here, the add - new item alert.scpt, attached to the Drop Box folder, pops up a notification whenever anybody puts a new item into your Drop Box folder.
After a script has been attached to a folder, you can edit the script file directly to modify its behavior. Control+click the folder to view the contextual menu, open the Edit a Folder Action submenu, and select the script you want to edit.
After making your changes, click Save and test the folder action again.
You can manage all the folders in the system that have folder actions attached at once. Control+click or right-click on or inside any Finder window or the Desktop to display the contextual menu and select Configure Folder Actions. A panel opens up that lists all configured folders and all the scripts assigned to each one. You can turn the individual scripts on and off, add or remove configured folders, and add or remove scripts from folders.
Select any script and click the Edit Script button to modify the script so that it does exactly what you want. If you have a lot of folder actions to manage, this is the most direct way to control them all.