http://www.hoboes.com/Mimsy/hacks/applescript-definitive/
AppleScript is an extremely useful tool for automating the repetitive things you do in Mac OS X applications, as well as for tying a long workflow together into a double-clickable icon. This Definitive Guide is a great reference for the AppleScript scripting language.