Previous Book Contents Book Index Next

Inside Macintosh: AppleScript Finder Guide /
Chapter 3 - Finder Commands / Command Definitions


A Duplicate command is a request to make a copy of an object or objects and insert the new copy either at a specified location or in the same container as the object that was copied. The Finder version of the Duplicate command is similar to the standard version described in the AppleScript Language Guide, except that the Finder's Duplicate command allows you to specify whether or not to replace items of the same name in the destination container.

duplicate referenceToObject [ to referenceToLocation ] �
   [ replacing ( conflicts | existing items ) ]
A reference to the object or objects to be duplicated.
Class: Reference
A reference to the location for the duplicated object or objects.
Class: Reference
Default value: If you don't specify a new location, the object is inserted in the same container as the original object and the word "copy" is appended to the new object's name.
A reference to the new object or a list of references.

This script duplicates a file to a disk, replacing any items at the top level of the disk that have the same name:

tell application "Finder"
   duplicate file "My File" of startup disk �
      to disk "Backup" replacing conflicts
end tell
You can use replacing existing items, with replacing, or replacing true instead of replacing conflicts without changing
the meaning of the script.

The statement duplicate items in referenceToContainer (where referenceToContainer is a reference to any container) won't compile. Instead,
use the statement duplicate every item of referenceToContainer.

Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996