O'Reilly logo

AppleScript® Programming for the Absolute Beginner by Jerry Lee Ford

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Printing Text Files

Although you will not learn how to interact with and automate Mac OS X applications until Chapter 8, “Automating Mac OS X Applications,” I thought I’d go ahead and show you how to use the TextEdit application to print text files that you generate with your AppleScripts. TextEdit is a free text editing Mac OS X application supplied as part of the operating system.

To interact with and control the TextEdit application, you will need to use the tell command to set up a code block in which you will embed commands that you want AppleScript to pass along to TextEdit for processing, as demonstrated here:

tell application "TextEdit"
     print (path to desktop folder as string) & "GroceryList.txt"
end tell

Here, TextEdit’s print command ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required