AppleScript_ The Definitive Guide - Matt Neuburg [7]
For example, suppose you've got a folder full of image files and you want to change their names in a systematic way to image01.jpg, image02.jpg, and so forth. It isn't as if you don't know how to do this: you select the first image file with the mouse, press Return to start editing its name, type image01.jpg, and press Return again; then you select the next image file with mouse, and do it again, and so forth. The trouble is that you don't want to do it. The trouble is with that "Do it again," which rapidly becomes tiresome and error-prone; before long, your eyes are starting to go out of focus, or you are just plain bored out of your skull, and you start to make mistakes. The whole thing is simultaneously too easy (it's an annoying waste of time and brain-power) and too hard (it's easy to make a mistake). It's just not a fit task for a human being. But it's a perfect task for a computer, which won't get bored or make a mistake no matter how many files are in that folder. AppleScript lets you assign to the computer tasks that are better suited to it than to a human being. And that example was a tiny one; AppleScript is just as useful for assembling massive workflows, driving big applications through massive tasks, feeding information from one to the other, processing and reformatting it in complex ways.
To find reasons to use AppleScript, just leave your mental annoyance meter turned on. Does something feel slow, repetitious, clumsy, boring, error-prone? Do you feel that a program isn't quite doing what you want? Does a series of steps need to be reduced to one? Has the computer got you trained, like some sort of laboratory animal, to perform a sequence of set tasks in a certain way? That's just not right. The computer should work for you—not the other way around! Maybe AppleScript can turn the tables.
I've been talking about "AppleScript," and in particular about an "AppleScript program" that's going to replace your hands and brain and make the computer do the work for you. But where does this program come from? Someone has to write it. That "someone" could be someone else: you can find lots of AppleScript programs that might be useful to you, already written and floating around on the Internet, where there's an entire community and culture of AppleScript users, sharing their work and benefiting from one another's experience. On the other hand, that "someone" could be you. That's why this book is here; it teaches you to write programs using AppleScript. That way, you'll be in charge of the automating power of your computer—a power which even now is lurking there, just waiting for you to take advantage of its vast potential. (And, as you'll see in Chapter 2, it's lurking in a lot of places.)
The rest of this chapter will illustrate the following general principles about what AppleScript is good for:
AppleScript is appropriate primarily when you want to automate an application.
AppleScript is good for expressing calculated and repetitive activity.
AppleScript is a means of reducing the number of steps needed to perform an action.
AppleScript is a way of customizing an application.
AppleScript lets you combine specialties: by automating more than one application, you make them work together, letting each application do what it's good at and uniting their several powers.
Is This Application Scriptable?
AppleScript isn't just a language; it's an underlying technology supporting that language. Because this technology is present as part of the system, you get it for free—so you may as well take advantage of it. And because you know this technology will be present on any Mac OS computer, you can share with others any useful AppleScript program you happen to write.
So AppleScript is omnipresent. But it's not omnipotent. AppleScript, remember, is all about telling an application to do automatically things of the sort you might make it do manually. But AppleScript does not let you tell every