AppleScript Finder GuideEnglish Dialect
xP R E F A C EAt the end of the guide are two appendixes and an index. Appendix A, “Finder Commands at a Glance,” summarizes the commands defined by t
CHAPTER 2 Finder Objects88 Object Class DefinitionsDEFAULT VALUE CLASS RETURNEDA reference to a sharing window or, if you use the plural form sharingwi
CHAPTER 2Finder ObjectsObject Class Definitions 89DEFAULT VALUE CLASS RETURNEDA reference to a file or, if you use the plural form sound files, a list o
CHAPTER 2 Finder Objects90 Object Class DefinitionsEXAMPLEIf a status window is open, this script returns its name:tell application "Finder"f
CHAPTER 2Finder ObjectsObject Class Definitions 91DEFAULT VALUE CLASS RETURNEDReference to a suitcase or, if you use the plural form suitcases, a list
CHAPTER 2 Finder Objects92 Object Class DefinitionsUnlike other containers, a trash-object also has these properties:warn before emptyingA Boolean valu
CHAPTER 2Finder ObjectsObject Class Definitions 93EXAMPLETo refer to a trash-object, you must use the Trash property of the desktop:tell application &q
CHAPTER 2 Finder Objects94 Object Class Definitionsposition Two integers that specify the position of the upper-left corner of the user’s icon.Class: L
CHAPTER 2Finder ObjectsObject Class Definitions 95Window 2An object of class window is any Finder window.PROPERTIESbounds The rectangle that bounds the
CHAPTER 2 Finder Objects96 Object Class Definitionsposition Two integers that specify the upper-left corner of the content region of the window. (The “
CHAPTER 2Finder ObjectsObject Class Definitions 97COMMANDS HANDLEDClean Up, Close, Count, Data Size, Exists, Get, Open, Print, Sort, UpdateDEFAULT VALU
xiP R E F A C EOther AppleScript Dialects 0A dialect is a version of the AppleScript language that resembles a particular human language or a programm
Using Command Definitions 99CHAPTER 3Finder Commands 3Figure 3-0Listing 3-0Table 3-0This chapter begins with a summary of the format used in command de
CHAPTER 3 Finder Commands100 Using Command DefinitionsFor example, here’s the syntax statement for the Move command from page 124:move referenceToObjec
CHAPTER 3Finder CommandsCommand Definitions 101Result 3Many (but not all) commands return results. The result of a command is the value generated when
CHAPTER 3 Finder Commands102 Command DefinitionsCount Counts elements of a particular class in a container. Behaves like the standard version, except t
CHAPTER 3Finder CommandsCommand Definitions 103Table 3-2 lists the commands defined by the Finder Suite—that is, the commands unique to the Finder.The r
CHAPTER 3 Finder Commands104 Command DefinitionsClean Up 3A Clean Up command is a request to align objects in a window or on the desktop along the grid
CHAPTER 3Finder CommandsCommand Definitions 105EXAMPLESThis script cleans up all of the Finder’s open windows (not including the desktop) for which “by
CHAPTER 3 Finder Commands106 Command DefinitionsHowever, if the window for a folder is open, you can use a script like this to clean up the contents of
CHAPTER 3Finder CommandsCommand Definitions 107EXAMPLESThis statement closes all Finder windows:tell application "Finder" to close windowsThi
CHAPTER 3 Finder Commands108 Command DefinitionsPARAMETERSgestaltSelector The Gestalt selector for the feature you want to test. The Finder converts th
CHAPTER 3Finder CommandsCommand Definitions 109This script returns an integer that indicates the total amount of memory available (including virtual me
CHAPTER 3 Finder Commands110 Command DefinitionsEXAMPLEThis script copies two files and places them in a folder on another disk:tell application "F
CHAPTER 3Finder CommandsCommand Definitions 111referenceToContainerA reference to the container whose elements are to be counted. If you do not specify
CHAPTER 3 Finder Commands112 Command Definitionslittle meaning for the Finder, because the result of a Get command for most Finder objects is a referen
CHAPTER 3Finder CommandsCommand Definitions 113EXAMPLEThis script returns a list of integers that specify the size, in bytes, of the icons for the files
CHAPTER 3 Finder Commands114 Command DefinitionsEXAMPLEtell application "Finder"delete file "OldFile" of startup diskend tell Dupli
CHAPTER 3Finder CommandsCommand Definitions 115EXAMPLEThis script duplicates a file to a disk, replacing any items at the top level of the disk that hav
CHAPTER 3 Finder Commands116 Command DefinitionsRESULTA reference to the ejected disk or a list of references.EXAMPLEThis script ejects the disk named
CHAPTER 3Finder CommandsCommand Definitions 117RESULTA reference to the trash container that was emptied.EXAMPLEtell application "Finder" to
Installation1CHAPTER 1Introduction to Finder Scripting 1Figure 1-0Listing 1-0Table 1-0Finder scripting refers to the use of AppleScript and an applica
CHAPTER 3 Finder Commands118 Command DefinitionsExists 3An Exists command is a request to determine whether the object specified by a reference exists.
CHAPTER 3Finder CommandsCommand Definitions 119elsedisplay dialog "The Storage cartridge isn’t mounted."end ifend tellNote that you can’t use
CHAPTER 3 Finder Commands120 Command DefinitionsRESULTA reference or list of references to the requested objects or, in the case of properties that con
CHAPTER 3Finder CommandsCommand Definitions 121NOTESThe word get in the Get command is optional. For example, these statements are equivalent:name of s
CHAPTER 3 Finder Commands122 Command DefinitionspropertyValue The value to assign to the property.Class: The value class of the property as specified in
CHAPTER 3Finder CommandsCommand Definitions 123If you save this script as an application and drag a folder onto the application’s icon, the script sear
CHAPTER 3 Finder Commands124 Command DefinitionsMove 3A Move command is a request to move an object or objects. The Finder version of the Move command
CHAPTER 3Finder CommandsCommand Definitions 125You can use replacing existing items, with replacing, or replacing true instead of replacing conflicts w
CHAPTER 3 Finder Commands126 Command DefinitionsRESULTReference to the opened object or a list of references.EXAMPLESThis script opens a file and a fold
CHAPTER 3Finder CommandsCommand Definitions 127SYNTAXprint referenceToObjectPARAMETERreferenceToObjectA reference to the object or objects to print—typ
CHAPTER 1 Introduction to Finder Scripting2What Is Finder Scripting?IMPORTANTFinder scripts that return a lot of information may need as much as sever
CHAPTER 3 Finder Commands128 Command DefinitionsPARAMETERreferenceToObjectA reference to the object to put away or a list of references.Class: Referenc
CHAPTER 3Finder CommandsCommand Definitions 129Quit 3A Quit command is a request to quit the Finder application. The Finder’s Quit command is similar t
CHAPTER 3 Finder Commands130 Command Definitionsallow you to relaunch the Finder with the Launch command (or with any Tell statement addressed to the F
CHAPTER 3Finder CommandsCommand Definitions 131Reveal 3The Reveal command is a request to make an object visible by opening its container and selecting
CHAPTER 3 Finder Commands132 Command DefinitionsSelect 3The Select command is a request to select one or more objects. If you specify objects in severa
CHAPTER 3Finder CommandsCommand Definitions 133Set 3The Set command is a request to set the values of one or more objects. The Finder version of the Se
CHAPTER 3 Finder Commands134 Command DefinitionsShut Down 3The Shut Down command is a request to shut down the computer. It is equivalent to choosing
CHAPTER 3Finder CommandsCommand Definitions 135PARAMETERSNoneRESULTNoneEXAMPLEtell application "Finder" to sleep Sort 3The Sort command is a
CHAPTER 3 Finder Commands136 Command DefinitionsEXAMPLESThis script returns a list of references to the folders in the startup disk, sorted by creation
CHAPTER 3Finder CommandsCommand Definitions 137Update 3An Update command is a request to update an object and its elements, if any, to match their repr
CHAPTER 1Introduction to Finder ScriptingWhat Is Finder Scripting? 3tell application "Finder"copy items of folder "AppleScript" of
Appendixes
Commands 141APPENDIX AFinder Commands at a Glance AThis appendix summarizes the commands described in this guide and the placeholders used in syntax d
APPENDIX A Finder Commands at a Glance142 CommandsTable A-1 Finder command syntax Command Syntax Result clean up clean up Reference or list of referen
APPENDIX AFinder Commands at a GlanceCommands 143eject eject Reference or list of referenceseject referenceToDiskempty empty Referenceempty referenceT
APPENDIX A Finder Commands at a Glance144 Commandsopen open referenceToObject Reference or list of referencesopen referenceToObject using referenceToA
APPENDIX AFinder Commands at a GlancePlaceholders 145Placeholders ATable A-2 explains the placeholders used in the syntax descriptions in this appendi
147APPENDIX BFinder Errors BThis appendix lists error numbers and error messages for errors returned by the Finder. For information about handling err
CHAPTER 1 Introduction to Finder Scripting4 What Is Finder Scripting?tell application "Finder" of machine "Macintosh IIci"repeat w
149IndexSymbols() in syntax descriptions xi[] in syntax descriptions xi| in syntax descriptions xiAAbout This Macintosh property, of the Finder applic
INDEX150command definitions (continued)Sleep 134–135Sort 135–136Update 137using 99–101commands 99–137parameters of 100summarized 141–144syntax of 99–10
INDEX151Finder Application object classdefined 31–37introduced 18–25Floating property, of a window 95Folder object class 63–65Folder propertyof a conta
INDEX152MMake Changes property, of sharing privileges 83Make command 121–123Minimum Partition Size property 40of an application file 38of an informatio
INDEX153Physical Size propertyof an information window 71of an item 74placeholders, in syntax descriptions xi, 145Position propertyof a group 68of an
INDEX154Stationery propertyof a file 62of an information window 71Status Window object class 89–90Suggested Partition Size property 40of an application
THE APPLE PUBLISHING SYSTEMThis Apple manual was written, edited, and composed on a desktop publishing system using Apple Macintosh computers and Fram
CHAPTER 1Introduction to Finder ScriptingRecording Actions in the Finder 5Recording Actions in the Finder 1You can record almost any actions in the Fi
CHAPTER 1 Introduction to Finder Scripting6 Recording Actions in the FinderListing 1-1 A sample recorded scripttell application "Finder"acti
CHAPTER 1Introduction to Finder ScriptingRecording Actions in the Finder 7window, turn on recording, choose the settings you want for each window from
Apple Computer, Inc.© 1994 Apple Computer, Inc.All rights reserved. No part of this publication or the software described in it may be reproduced, st
CHAPTER 1 Introduction to Finder Scripting8 Recording Actions in the FinderAfter you run the new script, the windows have the views specified in the sc
CHAPTER 1Introduction to Finder ScriptingRecording Actions in the Finder 9integers. For the Position property, the two integers specify the coordinate
CHAPTER 1 Introduction to Finder Scripting10 Writing Scripts That Control the FinderWriting Scripts That Control the Finder 1You can use a variety of
CHAPTER 1Introduction to Finder ScriptingWriting Scripts That Control the Finder 11Listing 1-2 A script that either takes a snapshot of the current wi
CHAPTER 1 Introduction to Finder Scripting12 Writing Scripts That Control the FinderListing 1-3 shows another script that uses the Display Dialog comm
CHAPTER 1Introduction to Finder ScriptingWriting Scripts That Control the Finder 13Unlike the script in Listing 1-2, the script in Listing 1-3 consist
Using Object Class Definitions 15CHAPTER 2Finder Objects 2Figure 2-0Listing 2-0Table 2-0This chapter begins with a summary of the format used in object
CHAPTER 2 Finder Objects16 Using Object Class Definitionstell application "Finder"set position of file "MyFile" to {29, 235}end tel
CHAPTER 2Finder ObjectsUsing Object Class Definitions 17Commands Handled 2Objects that belong to the same class can respond to the same commands. Objec
iiiContentsTables and Listings viiPreface About This GuideixAudience ixOrganization of This Guide ixFor More Information xGetting Started xAppleScript
CHAPTER 2 Finder Objects18 The Finder Application ObjectThe Finder Application Object 0The Finder application object belongs to the object class Appl
CHAPTER 2Finder ObjectsThe Finder Application Object 19To obtain a standard reference to an element of the Finder while you’re writing a script, follo
CHAPTER 2 Finder Objects20 The Finder Application ObjectProperties and Elements of the Finder 2The Finder application, like most other Finder objects,
CHAPTER 2Finder ObjectsThe Finder Application Object 21working area of your screen and not contained by a folder, disk, or other object—can be conside
CHAPTER 2 Finder Objects22 The Finder Application Objectwindow of startup disk of application "Finder", content space of desktop of applicat
CHAPTER 2Finder ObjectsThe Finder Application Object 23content space is a special case and the Finder doesn’t consider it a member of class Window (al
CHAPTER 2 Finder Objects24 The Finder Application ObjectYou can refer to windows by name, by number, or as the window property of the object to which
CHAPTER 2Finder ObjectsThe Finder Application Object 25References Returned for a Point 2To get a reference to the content space that lies under a part
CHAPTER 2 Finder Objects26 Object Class DefinitionsObject Class Definitions 2This section defines the Finder’s object classes. Accessory Process 2An obje
CHAPTER 2Finder ObjectsObject Class Definitions 27DEFAULT VALUE CLASS RETURNEDA reference or (if you use the plural form accessory processes) a list of
ivThe Finder Application Object 18Properties and Elements of the Finder 20References to Finder Windows 22References Returned for the Insertion Locatio
CHAPTER 2 Finder Objects28 Object Class DefinitionsELEMENT CLASSESThe only elements that an accessory suitcase can contain are objects of class Item (s
CHAPTER 2Finder ObjectsObject Class Definitions 29Like any other file, an alias file also has all the properties defined for object class Item on page 73:
CHAPTER 2 Finder Objects30 Object Class DefinitionsThe Get statement in this script returns a list of references to the selected items. The Repeat stat
CHAPTER 2Finder ObjectsObject Class Definitions 31Application 2An object of class Application is the Finder application itself, the outermost container
CHAPTER 2 Finder Objects32 Object Class Definitionsextensions folderA reference to the Extensions folder in the System Folder. This folder is used to s
CHAPTER 2Finder ObjectsObject Class Definitions 33product versionA string that describes the version of system software running on the same computer as
CHAPTER 2 Finder Objects34 Object Class Definitionstemporary items folderA reference to the Temporary Items folder in the System Folder. Applications u
CHAPTER 2Finder ObjectsObject Class Definitions 35File (page 61)Folder (page 63)Font File (page 65)Font Suitcase (page 66)Information Window (page 69)I
CHAPTER 2 Finder Objects36 Object Class DefinitionsThis statement identifies a folder:folder ID 918 of startup disk-—result: folder "My Folder"
CHAPTER 2Finder ObjectsObject Class Definitions 37DEFAULT VALUE CLASS RETURNEDReference.EXAMPLESThis script turns on the Calculate Folder Sizes propert
vChapter 3 Finder Commands99Using Command Definitions 99Syntax 99Parameters 100Result 101Examples 101Command Definitions 101Clean Up 104Close 106Compute
CHAPTER 2 Finder Objects38 Object Class DefinitionsSimilarly, the Finder interprets both of these statements as a reference to the Trash: trashtrash of
CHAPTER 2Finder ObjectsObject Class Definitions 39scriptable A Boolean value that indicates whether the application is high-level event aware (true) or
CHAPTER 2 Finder Objects40 Object Class Definitionstell application "Finder"set x to largest free blockset y to partition size of ¬applicatio
CHAPTER 2Finder ObjectsObject Class Definitions 41Minimum Partition size to 460,800 bytes (450K) and at the same time increases the Partition Size to 4
CHAPTER 2 Finder Objects42 Object Class DefinitionsELEMENT CLASSESNoneCOMMANDS HANDLEDCount, Data Size, Exists, Get, SortDEFAULT VALUE CLASS RETURNEDA
CHAPTER 2Finder ObjectsObject Class Definitions 43Container 2An object of class Container is any Finder container, such as a folder, a disk, or the Tra
CHAPTER 2 Finder Objects44 Object Class Definitionsexpandable A Boolean value that indicates whether the container can be opened within its container i
CHAPTER 2Finder ObjectsObject Class Definitions 45ELEMENT CLASSESObjects of these classes can be identified at the top level of a container by name or b
CHAPTER 2 Finder Objects46 Object Class DefinitionsEXAMPLESThe first example opens all the containers on the desktop except for the Trash.tell applicati
CHAPTER 2Finder ObjectsObject Class Definitions 47Container Window 2An object of class Container Window is a window for a container. For example, the
viAppendix A Finder Commands at a Glance141Commands 141Placeholders 145Appendix B Finder Errors147Index149
CHAPTER 2 Finder Objects48 Object Class DefinitionsYou can’t get or set this property unless the container window is open, and the value of the propert
CHAPTER 2Finder ObjectsObject Class Definitions 49Font File (page 65)Font Suitcase (page 66)Item (page 73)Sharable Container (page 79)Sound File (page
CHAPTER 2 Finder Objects50 Object Class DefinitionsThe phrase count of container windows at the beginning of the Repeat loop requests that the Finder c
CHAPTER 2Finder ObjectsObject Class Definitions 51EXAMPLEThis script returns a list of all Finder content spaces that are currently open, including the
CHAPTER 2 Finder Objects52 Object Class Definitionscalculate folder sizes A Boolean value that indicates whether the checkbox labeled “Calculate folder
CHAPTER 2Finder ObjectsObject Class Definitions 53label headingA Boolean value that indicates whether the checkbox labeled “Show label” in the Views co
CHAPTER 2 Finder Objects54 Object Class DefinitionsELEMENT CLASSESNoneCOMMANDS HANDLEDClean Up, Close, Copy, Count, Data Size, Delete, Duplicate, Exist
CHAPTER 2Finder ObjectsObject Class Definitions 55Desk Accessory File 2An object of class Desk Accessory File is a desk accessory file on a disk.PROPERT
CHAPTER 2 Finder Objects56 Object Class DefinitionsDesktop-Object 2An object of class Desktop-Object is the desktop of a computer. The Desktop property
CHAPTER 2Finder ObjectsObject Class Definitions 57Folder (page 63)Font File (page 65)Font Suitcase (page 66)Item (page 73)Sharable Container (page 79)S
viiTables and ListingsChapter 1Introduction to Finder Scripting1Listing 1-1 A sample recorded script 6Listing 1-2 A script that either takes a snapsho
CHAPTER 2 Finder Objects58 Object Class DefinitionsPROPERTIESA disk has all the properties defined for object class Sharable Container on page 79: Expor
CHAPTER 2Finder ObjectsObject Class Definitions 59ELEMENT CLASSESObjects of the classes listed here can be identified at the top level of a disk by name
CHAPTER 2 Finder Objects60 Object Class DefinitionsEXAMPLEThe script that follows tests the Ejectable property of each item in a list of the mounted di
CHAPTER 2Finder ObjectsObject Class Definitions 61EXAMPLEThis script opens all the document files at the top level of a disk:tell application "Find
CHAPTER 2 Finder Objects62 Object Class Definitionsproduct versionThe version number shown at the top of the information window for the file.Class: Stri
CHAPTER 2Finder ObjectsObject Class Definitions 63If you save this script as a script application, it copies a new icon to any files whose icons you dro
CHAPTER 2 Finder Objects64 Object Class DefinitionsELEMENT CLASSESObjects of these classes can be identified at the top level of the folder by name or b
CHAPTER 2Finder ObjectsObject Class Definitions 65EXAMPLEThis script returns references to all the folders at the top level of the startup disk that ha
CHAPTER 2 Finder Objects66 Object Class DefinitionsDEFAULT VALUE CLASS RETURNEDA reference to a file or, if you use the plural form font files, a list o
CHAPTER 2Finder ObjectsObject Class Definitions 67COMMANDS HANDLEDClean Up, Close, Copy, Count, Data Size, Delete, Duplicate, Exists, Get, Move, Open,
CHAPTER 2 Finder Objects68 Object Class DefinitionsGroup 2An object of class Group is a group file in the Users & Groups control panel window. The F
CHAPTER 2Finder ObjectsObject Class Definitions 69COMMANDS HANDLEDClean Up, Close, Count, Data Size, Exists, Get, Make, Open, Select, Sort, UpdateDEFAU
CHAPTER 2 Finder Objects70 Object Class DefinitionsUnlike other windows, an information window also has these properties:comment The comment displayed
CHAPTER 2Finder ObjectsObject Class Definitions 71partition sizeAn integer indicating the amount of memory, in bytes, that an application is launched w
CHAPTER 2 Finder Objects72 Object Class Definitionswarn before emptyingA Boolean value that indicates whether the Finder should warn the user before em
CHAPTER 2Finder ObjectsObject Class Definitions 73Item 2An object of class Item is any item in a container.PROPERTIESbounds The coordinates of the rect
CHAPTER 2 Finder Objects74 Object Class Definitionsid The item’s hierarchical file system (HFS) ID number, an integer that identifies an application file,
CHAPTER 2Finder ObjectsObject Class Definitions 75size The logical size of the item on disk, in bytes.Class: IntegerModifiable: Nowindow A reference to
CHAPTER 2 Finder Objects76 Object Class Definitionsproperty Extras : falsetell application "Finder"if (exists item " Add Extras" of
CHAPTER 2Finder ObjectsObject Class Definitions 77items in the Apple Menu Items folder, and its name changes to Remove Extras after the extra items hav
ixP R E F A C EAbout This GuideThe AppleScript Finder Guide: English Dialect describes the commands and object classes defined by the Finder for use wi
CHAPTER 2 Finder Objects78 Object Class Definitionspartition sizeAn integer indicating the amount of memory, in bytes, that a process is launched with
CHAPTER 2Finder ObjectsObject Class Definitions 79DEFAULT VALUE CLASS RETURNEDA reference or (if you use the plural form processes) a list of reference
CHAPTER 2 Finder Objects80 Object Class DefinitionsUnlike other containers, a sharable container also has these properties:exported A Boolean value tha
CHAPTER 2Finder ObjectsObject Class Definitions 81set to false if you set any of the group, guest, or owner privileges individually.Class: BooleanModifi
CHAPTER 2 Finder Objects82 Object Class DefinitionsELEMENT CLASSESObjects of these classes can be identified at the top level of a sharable container by
CHAPTER 2Finder ObjectsObject Class Definitions 83EXAMPLEThis script changes the Shared property to false for all sharable containers that belong to a
CHAPTER 2 Finder Objects84 Object Class Definitionssee foldersA Boolean value that corresponds to the See Folders checkbox for a specified user or group
CHAPTER 2Finder ObjectsObject Class Definitions 85Sharing Window 2An object of class Sharing Window is a sharing window that appears when you choose S
CHAPTER 2 Finder Objects86 Object Class Definitionsgroup privilegesThe group privileges selected in the sharing window. For example, if the See Folders
CHAPTER 2Finder ObjectsObject Class Definitions 87owner privilegesThe owner privileges selected in the sharing window. For example, if the See Folders
Comments to this Manuals