O'Reilly logo

AppleScript in a Nutshell by Bruce W. Perry

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

Finder Commands

Synopsis

The following commands can be used by enclosing them in a tell statement that targets the Finder, as in:

tell app "Finder" to sleep

Dictionary commands

add to favorites reference

The Apple Menu in the upper left corner of the Mac OS 9 screen has a Favorites menu item that includes folders and programs that are displayed or executed if you select them. You can use this command to add to the Favorites list:

tell application "Finder" to add to favorites (folder "today" of desktop)

This adds a folder called today on the desktop to the Favorites menu.

clean up reference

This command neatly arranges buttons or icons in an open window or on the desktop:

tell application "Finder" to clean up window "HFSA2gig"

(See the Finder’s View menu, which determines how Finder items like folders are aligned on the desktop.) If you use clean up all, this command has the same effect as clean up desktop by name.

by property

This labeled parameter determines how items are arranged; e.g., by comment, modification date, name, size, or version. An example is:

clean up desktop by name

This Finder command arranges the desktop items by their name in alphabetical order.

close reference

Use the close command followed by a reference to one or more windows. An example is:

tell application "Finder" to close window "HFSA2gig"

You can also close multiple objects:

tell app "Finder" to close every window

This command closes every Finder window on the desktop, such as folder or disk windows.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required