Copy Command

Copy command examples, options, switches, and more

Screenshot of the copy help switch and results in the Windows 10 Command Prompt
Copy Command Options (Windows 10 Command Prompt).

The copy command is a Command Prompt command used to copy a file from one location to another.

The copy command is especially helpful when you're working in the command line because you can't right-click and copy files to paste them into other folders or hard dives like you can when using the normal copy function in Windows.

With the copy command, you can 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 file extensions. Some other copy command options include the ability to verify that the files were copied correctly, and suppress prompts to overwrite files of the same name.

Copy Command Availability

The copy command is available from within the Command Prompt in 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 copy command is also a Recovery Console command used within the Recovery Console in Windows 2000 and Windows XP, and a DOS command available in MS-DOS.

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

Copy Command Syntax

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

Tip: 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.

  • /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.

    You can also append files by choosing multiple source files but just one single destination file.

    Copy Command Examples

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

    The copy command above will copy program.iso from the Z: drive to the Downloads\Programs folder.

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

    You can use the copy command to rename a file and even change the file's extension. In the example above, the j93n.exe file is being copied 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. The example below is similar...

    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 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, the readme.htm file will be copied to C:\Windows.

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

    This example of the copy command will copy 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 tell us whether the files were actually copied or if an error happened in the process.

    Note: A folder has to already exist in the destination location before the copy command will copy files to it. You can make new folders in Command Prompt with the mkdir command.

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

    The copy command example above merges three TXT files into one new TXT file 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.

    In our example, each text file in the source area (right after the word "copy") reads "1st ," "2nd ," and "3rd " on the first line of the document. When combined into one with the copy command, the combined.txt file reads "1st 2nd 3rd," all on the first line.

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

    Copy Related Commands

    The copy command is similar to the xcopy command, but unlike copy, xcopy is able to make copies of folders.