Apple AppleScript Finder Guide User Manual
Page 117

C H A P T E R 3
Finder Commands
Command Definitions
105
EXAMPLES
This script cleans up all of the Finder’s open windows (not including the
desktop) for which “by Icon” or “by Small Icon” is selected in the Views menu.
The by name parameter specifies that the cleaned up icons are to be arranged
in the windows by name.
tell application "Finder"
clean up windows by name
end tell
This script aligns the icons in the window for the disk My World to the nearest
grid points without sorting them into a new arrangement:
tell application "Finder"
clean up window "My World"
end tell
NOTES
The command clean up all is equivalent to the command clean up
desktop by name
and to the Clean Up All menu command (available when
you select an item on the desktop, hold down the Option key, and pull down
the Special menu). All these commands rearrange items on the desktop by
name and place the Trash in its original position relative to the lower-right
corner of the screen. However, if you use the Clean Up command without any
parameters, the Finder aligns objects on the desktop to the nearest grid points
without rearranging them.
If the referenceToObject parameter of the Clean Up command is a reference to
one or more items in an open window or on the desktop, the command aligns
their icons to the grid but ignores the propertyLabel parameter, if any. For
example, this script aligns only the icon for the folder My Folder (not the
contents of My Folder) to the grid:
tell application "Finder"
clean up folder "My Folder" of window "My World"
end tell