beautypg.com

Apple AppleScript Finder Guide User Manual

Page 148

background image

C H A P T E R 3

Finder Commands

136

Command Definitions

EXAMPLES

This script returns a list of references to the folders in the startup disk, sorted

by creation date:

tell application "Finder"

sort folders in startup disk by creation date

end tell

--result: {folder "Letters" of startup disk of
application "Finder", folder "Projects" of startup disk
of application "Finder", folder "Current Correspondence" of
startup disk of application "Finder"}

This script sorts files from several different folders by size.

tell application "Finder"

sort {files in startup disk, files in disk "Data"} ¬

by size

end tell

--result: {file "George" of startup disk of application
"Finder", file "Notes" of disk "Data" of application
"Finder", file "Expenses" of startup disk of application
"Finder"}

NOTES

The Sort command usually sorts in ascending order; for example, if you sort by

name, the resulting references are sorted alphabetically by name. When you

sort by creation date or modification date, the Sort command returns a list of

references sorted in descending order from the newest item to the oldest.
To sort the actual items that are displayed in a window, rather than a list of

references to those items, either set the View property of the window or, if the

items are displayed by icon or by small icon, use the Clean Up command as

described on page 104.