Chapter 11. Linking Scripts to Folders with Folder Actions


Imagine: your Mac reminds you to clean the sink whenever you open your Applications folder. You automatically see a dialog box whenever someone on your network drops a file in your Public folder. And your desktop automatically cleans itself up when you fill it with too many icons.

Now stop dreaming. Everything you just imagined is only a script away, thanks to the special folder actions feature you get with AppleScript and Mac OS X.

If you've used Mail rules before (Sidebar 9.4), you'll instantly understand the power of folder actions. That's because Mail rules and folder actions are based on the same idea: triggering scripts automatically when something happens on your Mac.

A folder action is an AppleScript like any other. The difference is that you can attach a folder action to a specific folderand have the script run automatically when you do something to that folder. You can trigger a folder action when you open a folder, close a folder, or copy items into a folder, for example. With triggers like these, the scripting possibilities are truly limitless.

The example scripts from this chapter can be found on the AppleScript Examples CD (see Sidebar 2.1 for instructions).



AppleScript. The Missing Manual
AppleScript: The Missing Manual
ISBN: 0596008503
EAN: 2147483647
Year: 2003
Pages: 150

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net