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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.