Writing Your Own AppleScripts

If you ask a crowd of Mac users how many of them write AppleScripts, few hands are likely to go up. That’s too bad, because as programming languages go, AppleScript is easy to understand. It takes only a few weeks, not years, to become comfortable with AppleScript. And the power AppleScript places in your hands is well worth the effort you’ll expend learning it.

For example, here’s a fragment of actual AppleScript code:

open folder "AppleScript" of folder "Applications" of startup disk

You probably don’t need a manual to tell you what this line from an AppleScript program does. It opens the ApplicationsAppleScript folder on your hard drive. (That’s the folder that contains Script Editor, the Mac OS X program that lets you write your own AppleScripts, and Script Menu.menu, described in Section 7.1.)

If you have no interest in learning to program, you’re forgiven; you’re not alone. But almost every Mac user can benefit by understanding what AppleScript can do, why it’s important in certain industries, and how it may be useful in special situations. Even skimming this section will give you an appreciation of AppleScript’s power—and yet another reason to relish being a Mac user: Windows has no equivalent of AppleScript. And with AppleScript’s ability to tie into Terminal to run Unix commands, the power available to you has become even greater.

Get Mac OS X: The Missing Manual, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.