Copy Command

Duplicate a file and store it in a different place with the 'copy' command

The copy Command Prompt command duplicates a file, storing the second version in a different location of your choosing.

Use the command to copy a file using its specific name and file extension or use a wildcard to copy groups of files at once, regardless of the file names or extensions. Some other command options include verification that the files were copied correctly and suppression of prompts to overwrite files of the same name.

Copy Command Availability

Copy command options in Windows 11 Command Prompt
Copy Command Options (Windows 11 Command Prompt).

The copy command is available from within the Command Prompt in Windows 11, Windows 10, Windows 8, Windows 7, Windows Vista, and Windows XP, as well as from the Advanced Startup Options and System Recovery Options repair/recovery menus.

The availability of certain copy command switches and other command syntax might differ from operating system to operating system.

Copy Command Syntax

The command accepts the following general form:

copy [/d] [/v] [/n] [/y /-y] [/z] [/l] [/a | /bsource [/a | /b] [+ source [/a | /b] [+ ...]] [destination [/a | /b]] [/?]

See How to Read Command Syntax if you're not sure how to interpret the copy command syntax as it's described above or in the list below.

Copy Command Options
Item Explanation
/d Allows the destination file to be created decrypted.
/v Verifies that new files are written correctly.
/n Uses short file name, if available, when copying a file with a non-8dot3 name.
/y Suppresses confirmation prompts to overwrite the destination file if it's the same name as the source file.
/-y Shows confirmation prompts to overwrite a file if the source file name is identical to the destination file name.
/z Copies networked files in restartable mode.
/l Copies the link to source instead of the actual file that source points to. This is only relevant if source is a symbolic link.
/a Indicates an ASCII text file.
/b Indicates a binary file.
source  This is the location and name of the file you want to copy. The source may not be a folder and you may not use wildcard characters (the asterisk).
destination This is the location and/or file name that the file specified in source should be copied to.
/? Use the help switch with the copy command to show detailed help about the command's several options.

Append files by choosing several source files but just one destination file.

Copy Command Examples

Below are several examples of how to use the copy command:

Copy to a Different Folder

copy Z:\Software\program.iso C:\Users\Jon\Downloads\Programs\

The copies program.iso from the Z: drive to the user's Programs folder.

Copy and Rename

copy Y:\install\j93n.exe Y:\more\m1284.msi

You can use the copy command to rename a file and even change its file extension. In this example, the j93n.exe file copies to a new folder on the Y: drive as m1284.msi.

This isn't a file conversion technique (i.e., the EXE file isn't really being converted to MSI) but instead a way to make an identical copy but with the destination file saved under a different name and inside a different folder.

copy D:\i386\atapi.sy_ C:\Windows\atapi.sys

In the above example, the atapi.sy_ file, located in the i386 folder on the Windows XP installation CD, is copied to the C:\Windows directory as atapi.sys.

Unlike the Y: drive example above, this one is a bit more realistic, since copying files like that from a disc is a common practice when fixing some specific Windows problems.

Copy to Current Path

copy D:\readme.htm

In this example, the copy command has no destination specified, so the readme.htm file is copied to whatever directory you typed the copy command from.

For example, if you type copy d:\readme.htm from the C:\Windows> prompt, that HTM file will be copied to C:\Windows.

Copy Only Certain File Types

copy /y /v C:\Users\Jon\Downloads\*.mp3 C:\Users\Jon\Music\DownloadedMusic\

This command copies all MP3s (*.mp3) from the Downloads folder to the Music\DownloadedMusic\ folder, but we want to make sure that every file is copied, even if there's already one in DownloadedMusic with the same name (/y). We'll verify the copy (/v) to make sure Command Prompt tells us whether the files were actually copied or if an error happened in the process.

A folder has to already exist in the destination location before the copy command will copy files to it. Make new folders in Command Prompt with the mkdir command.

Merge Files Into One

copy Z:\file1.txt+Z:\file2.txt+Z:\file3.txt Z:\combined.txt

This will merge three TXT files into a new one called combined.txt. As you can see, each file that should be part of the merge need to be separated by a + sign, but no spaces.

You can also use the asterisk to append multiple files. So, in our example, we could replace all those .txt instances with Z:\*.txt, but only if we want to merge every single TXT file from the Z: drive.

Copy Related Commands

This command is similar to the xcopy command, but unlike copy, xcopy works on folders, too.

Was this page helpful?