There is apple script, which you can find more info about here:
http://www.apple.com/macosx/features/applescript/. I couldn't find any scripts already written, but you should be able to write some simple ones for your self using the recorder.
Also in the new OS coming out in the fall, automator is supposed to have a lot of new features.