Chapter 17. Working with Files

In this chapter, you will learn about the various features AppleScript uses to identify files, folders, and disks, and how to read and write files using Standard Additions.

Identifying Files, Folders, and Disks

When you work with files, you need a way to refer to them. No matter whether your goal is creating a text file, backing up some folders, or deleting the entire contents of a hard disk, the ways you refer to a file are the same.

AppleScript can identify a file, folder, or disk in four general ways, and your job is to choose the method that works best in your situation, with the application you're using:

  • An HFS or POSIX path string

  • An AppleScript object of class alias, file, or POSIX file (though there is a catch ...

Get Learn AppleScript: The Comprehensive Guide to Scripting and Automation on Mac OS X, Third 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.