Automation

Along with creating a number of useful utilities, AppleScript has won a reputation as a premier tool for automating software workflows. In workflows, one or more separate software programs cooperate in a sequence of actions to complete a job. This means that launching an AppleScript can orchestrate several actions that involve software applications that are not otherwise designed to share data or call each other’s menu commands. AppleScript does the calling of each program’s commands (targeting them in a similar manner to how the Finder is targeted in Example 1-1), acting as a conductor for busy software medleys. AppleScript has earned the undying loyalty of many Mac scripters in the print and web publishing industries by its ability to simultaneously control applications such as QuarkXPress, Adobe Illustrator, InDesign, and Photoshop, Canto Cumulus, FileMaker Pro, as well as the Microsoft Office members like Word and Excel.

As an example of automation, I designed an AppleScript in the summer of 2000 to convert thousands of text files to web pages. A company that publishes legal decisions wanted to make them available to a search engine on their web site. Since they were already plain text or Word files, and the page designs were very simple, we used an AppleScript to feed the pages to Word and to trigger its “Save as HTML...” menu command (which creates a simple, almost crude, web-page design at best). The company converted about 20,000 legal decisions in a matter ...

Get AppleScript in a Nutshell 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.