Referring to items in the Finder
To control Finder items such as files and folders, you need to specify the items in the script. There are several ways to refer to items. In addition, you can use AppleScript terms to specify groups of files. Types of references There are three ways to refer to a file or folder in a script. Each type of reference indicates the name of the item, the type of item, and its location on your computer. Finder references: file "Art.gif" of folder "Images" of disk "Macintosh HD" A Finder reference can include these names of special folders and disks: You don't need to use quotation marks with these shortcuts. Here are two examples: file "Art.gif" of folder "Images" of startup disk file "My Prefs" of preferences folder Path references: file "Macintosh HD:Images:Art.gif" folder "Macintosh HD:Images:" Alias references: alias "Macintosh HD:Images:Art.gif" alias "Macintosh HD:Images:" Alias references in a script work much the same way that aliases work in the Finder. Finder and path references are absolute, so a script will not work if you move the item they refer to. If you use an alias reference, the alias will contain the file's location, even if it's moved, so the script will always work. If you reference items on remote disks: Pasting references Rather than typing a reference, you can copy and paste it. To paste a Finder reference to a file or folder into a script:
Identifying items AppleScript includes terms that let you specify groups of items in various ways. Every: set my_list to every file of folder "Process Files" Whose and Where Its: set my_list to every file of folder "Process Files" whose¬ set my_list to every file of folder "Process Files" where its¬ These two statements would have the same result. This example refers to folders by their label property: set my_list to every file of the startup disk whose¬ And and Or: set my_list to every file of folder "Process Files" whose¬ Entire Contents: set my_list to every file of the entire contents of folder¬ Related topic
|
||||||||||||||||||||
Table of contents |