Tools: MPW
Advanced Search
Apple Developer Connection
Member Login Log In | Not a Member? Support

MPW Command Reference


Duplicate

Built-in

SYNTAX

Duplicate name1 [name2]… targetName [-c | -n | -y] [-d | -r] [-f] [-p]
[-rs] [-rt]

DESCRIPTION

The Duplicate command copies one or more files, directories, or volumes (name1 [name2]…) to a destination file or directory (targetName). Items copied to the destination are given the same creation and modification dates as their source.

A dialog requests confirmation before overwriting an existing file or folder of the same name. You can use the -c, -n, or -y options to handle this request noninteractively. This is especially useful for scripts.

INPUT

None

OUTPUT

None

ALIAS RESOLUTION

By default, the Duplicate command does not resolve leaf Finder aliases for either the source parameter (name1 [name2]…) or the target parameter (targetName). This allows you to duplicate or overwrite Finder alias files.

You can override this default behavior and instruct Duplicate to resolve Finder aliases for either the source parameter or the target parameter by using the options -rs or -rt, respectively.

STATUS

Duplicate can return the following status codes:

0

all objects duplicated

1

syntax error

2

any other error

4

cancel selected or implied (-c)

PARAMETERS

name1 [name2]…

Specifies one or more files, directories, or volumes to be copied to the destination. If you specify any directories, Duplicate also copies their subdirectories. Note that none of the directories specified can be the parent of targetName.

targetName

Specifies a destination file or directory. If you specify a nonexistent file, Duplicate copies the source item and renames it targetName. When copying multiple items, targetName must be a folder and must already exist.

Specifying a file as the destination allows you to copy only one source file. Making targetName a directory, on the other hand, allows you to copy any number of source files, directories, and volumes.

OPTIONS

-c

Prevents the display of any confirmation dialogs by automatically responding Cancel. This causes Duplicate to abort before overwriting any existing files or directories.

-d

Duplicates the data fork only. If targetName is an existing file, its data fork is overwritten and its resource fork remains untouched.

-f

Preserves Finder locations. Using -f ensures that the duplicate file appears in the same location as the original (that is, the duplicate file's icon appears in the same physical location). The default is to relocate the file to a position of the Finder's choice.

-n

Prevents the display of any confirmation dialogs by automatically responding No. This causes Duplicate to not overwrite files or folders that already exist.

-p

Writes progress information to diagnostic output, such as listing items as they are copied to the destination.

-r

Duplicates the resource fork only. If targetName is an existing file, its resource fork is overwritten and its data fork remains untouched.

-rs

Resolves leaf aliases in all source paths. For instance, if the source parameter is a Finder alias that references a directory, then this option resolves the Finder alias, and the directory that the Finder alias references is duplicated.

-rt

Resolves leaf aliases in the target path. For instance, if the source parameter (name1) is one item and targetName is an alias file, then this option resolves the Finder alias and the contents of name1 overwrite the file that the Finder alias references.

-y

Prevents the display of any confirmation dialogs by automatically responding Yes. This causes existing files or folders to be overwritten.

Note
If you use the Backup command's -y option, this -y option is suppressed in the output of Backup. •

EXAMPLES

Assuming Monthly Reports is an existing directory, the command line

Duplicate Aug96 "Monthly Reports"

duplicates the file Aug96 into that directory.

The following command line duplicates File1 and Folder1 (including its contents) onto Backup Disk.

Duplicate File1 Folder1 "Backup Disk:"

The following command line duplicates File1 to File2, overwriting File2 if it exists:

Duplicate File1 File2 -y

Using the ≈ wildcard character to match all files, the command line

Duplicate Disk1:≈ "{MPW}"

copies all the files in the Disk1 directory into the {MPW} directory. Note that files within subdirectories are not copied.

The following command line copies the entire contents of the Disk1 directory (including nested files and subdirectories) to the {MPW} directory.

Duplicate Disk1: "{MPW}"

SEE ALSO

Backup

Move

Rename

 
 


Last Updated July 2000