DekGenius.com
Team LiB   Previous Section   Next Section
first, second, third, fourth, etc.

Syntax

tell app "Finder" to get 75th file of extensions folder

Synonyms

Index

[-]integernd, [-]integerrd, [-]integerst, [-]integerth

Description

You can identify an object by its numerical position in a folder or other container. For numbers 1-10 you can use the word forms (first, second, third ), such as eighth file of startup disk. For numerical positions greater than 10, you have to use an integer (optionally preceded by the minus sign) followed by any one of the four suffixes (e.g., "rd"), even if it doesn't sound right. Telling the Finder to:

get 75rd file of extensions folder

is legal. A negative integer searches the container in the opposite direction, from its last item to its first. For example, get file -1 (when targeting the Finder) gets the last file on the desktop. You can also use the index reference style in the following manner:

disk index 2

The index reserved word is optional; mostly you will just use the index-less style:

folder 3 of Startup disk

Examples

tell app "BBEdit 5.0" to get -1000th word of document 1 (* gets 1,000th word 
searching from the document end *)

tell app "Sherlock 2" to get third channel (* channel surfing Sherlock 2 
returns 'channel "Internet" of application "Sherlock 2"' *)

tell app "Sherlock 2" to get tenth channel (* will raise an error if the 
container (e.g., the Sherlock 2 app) does not have ten of the objects, in this 
case channels *)
    Team LiB   Previous Section   Next Section