Copy


Applies To: Windows Vista,Windows Server 2008

Copies one or more files from one location to another.

For examples of how to use this command, see Examples.

Syntax


Copy Code

copy [/d] [/v] [/n] [/y | /-y] [/z] [/a | /b] <Source> [/a | /b] [+<Source> [/a | /b] [+ ...]] [<Destination> [/a | /b]]

Parameters

Parameter

Description

/d

Allows the encrypted files being copied to be saved as decrypted files at the destination.

/v

Verifies that new files are written correctly.

/n

Uses a short file name, if available, when copying a file with a name longer than eight characters, or with a file name extension longer than three characters.

/y

Suppresses prompting to confirm that you want to overwrite an existing destination file.

/-y

Prompts you to confirm that you want to overwrite an existing destination file.

/z

Copies networked files in restartable mode.

/a

Indicates an ASCII text file.

/b

Indicates a binary file.

<Source>

Required. Specifies the location from which you want to copy a file or set of files. Source can consist of a drive letter and colon, a directory name, a file name, or a combination of these.

<Destination>

Required. Specifies the location to which you want to copy a file or set of files. Destination can consist of a drive letter and colon, a directory name, a file name, or a combination of these.

/?

Displays help at the command prompt.

Remarks


Copy Code

copy /b <Source> +,,

The commas indicate the omission of the Destination parameter.

Examples

To copy a file called Memo.doc to Letter.doc in the current drive and ensure that an end-of-file character (CTRL+Z) is at the end of the copied file, type:


Copy Code

copy memo.doc letter.doc /a

To copy a file named Robin.typ from the current drive and directory to an existing directory named Birds that is located on drive C, type:


Copy Code

copy robin.typ c:\birds

If the Birds directory does not exist, the file Robin.typ is copied into a file named Birds that is located in the root directory on the disk in drive C.

To combine Mar89.rpt, Apr89.rpt, and May89.rpt, which are located in the current directory, and place them in a file named Report (also in the current directory), type:


Copy Code

copy mar89.rpt + apr89.rpt + may89.rpt Report

When you combine files, copy marks the destination file with the current date and time. If you omit Destination, the files are combined and stored under the name of the first file in the list. For example, to combine all files in Report when a file named Report already exists, type:


Copy Code

copy report + mar89.rpt + apr89.rpt + may89.rpt

To combine all files in the current directory that have the.txt file name extension into a single file named Combined.doc, type:


Copy Code

copy *.txt Combined.doc

If you want to combine several binary files into one file by using wildcard characters, include /b. This prevents Windows from treating CTRL+Z as an end-of-file character. For example, type:


Copy Code

copy /b *.exe Combined.exe

Caution

If you combine binary files, the resulting file might be unusable due to internal formatting.

In the following example, copy combines each file that has a .txt extension with its corresponding .ref file. The result is a file with the same file name but with a .doc extension. Copy combines File1.txt with File1.ref to form File1.doc, and then copy combines File2.txt with File2.ref to form File2.doc, and so on. For example, type:


Copy Code

copy *.txt + *.ref *.doc

To combine all files with the .txt extension, and then combine all files with the .ref extension into one file named Combined.doc, type:


Copy Code

copy *.txt + *.ref Combined.doc

Additional references

Command-Line Syntax Key