Name

alias

Allowed coercions

list with one item, as in: {alias "Macintosh HD:Desktop Folder:newfile.txt"}
string

Syntax

set theFile to alias "Macintosh HD:Desktop Folder:newfile.txt"

Description

An alias type is a representation of a disk, folder, or volume. An alias is a form of referring to an object such as a file (as in the syntax example), which is very similar to the “alias files” that you can create in the Finder.

Tip

An alias file is a Finder object that can be referred to in tell statements that target the Finder. An alias (such as the alias in the syntax example), on the other hand, is a built-in AppleScript class or type.

Nearly everyone who has used a Macintosh is familiar with making alias files (i.e., select the file and type Command-M or choose File Make Alias from the Finder’s menu in Mac OS 9). For example, if you have a file called new.txt and you make an alias out of it, then the Finder creates a new file in the same location that looks like Figure 3-1. This file refers to the original file by using a unique identifier. Even if you move the original file around within the volume (which is represented by a disk icon on OS 9’s desktop), but not outside of the volume, the alias file will still find it. An alias value type is similar to an alias file. Every time you change and recompile a script that refers to an alias, AppleScript will attempt to find the file or other object that the alias refers to. A lot of commonly used commands take aliases for arguments (such ...

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.