MS-DOS and Windows command line copy command
The copy command allows users to copy one or more files to an alternate location.
Note: We use the copy command for complete files, if you want to copy a directory, or multiple directories containing files, use the robocopy or xcopy command. If you want to copy text within a file, see: How to copy and paste text in a document or another program.
Availability
Copy exists as an internal command and Microsoft makes it available for the following Microsoft operating systems.
- All Versions of MS-DOS
- Windows 95
- Windows 98
- Windows ME
- Windows NT
- Windows 2000
- Windows XP
- Windows Vista
- Windows 7
- Windows 8
- Windows 10
Copy syntax
Windows Vista and later syntax
COPY [/D] [/V] [/N] [/Y | /-Y] [/Z] [/L] [/A | /B ] source [/A | /B] [+ source [/A | /B] [+ ...]] [destination [/A | /B]]
source | Specifies the file or files to be copied. |
/A | Indicates an ASCII text file. |
/B | Indicates a binary file. |
/D | Allow the destination file to be created decrypted. |
destination | Specifies the directory or file name for the new file(s). |
/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 prompting to confirm you want to overwrite an existing destination file. |
/-Y | Causes prompting to confirm you want to overwrite an existing destination file. |
/Z | Copies networked files in restartable mode. |
/L | If the source exists as a symbolic link, copy the link to the target instead of the actual file the source link points to. |
You may preset switch /Y in the COPYCMD environment variable. You can override this with /-Y on the command line. The default prompts on overwrites unless you are executing the COPY command from within a batch script.
To append files, specify a single file for destination, but multiple files for source (using wildcards or file1+file2+file3 format).
Windows XP and earlier syntax
COPY [/A | /B] source [/A | /B] [+ source [/A | /B] [+ ...]] [destination] [/A | /B]] [/V] [/Y | /-Y]
source | Specifies the file or files to copy. |
/A | Indicates an ASCII text file. |
/B | Indicates a binary file. |
destination | Specifies the directory or file name for the new file(s). |
/V | Verifies the correctness of the new files. |
/Y | Suppresses prompting to confirm you want to overwrite an existing destination file. |
/-Y | Causes prompting to confirm you want to overwrite an existing destination file. |
The switch /Y may be preset in the COPYCMD environment variable. You can override this setting with /-Y on the command line.
To append files, specify a single file for destination, but multiple files for source (using wildcards or file1+file2+file3 format).
Copy examples
copy *.txt c:\
In the example above, we use a wildcard to copy all .txt files (multiple files) from the current directory to the c:\ root directory.
copy *.* a:
Copy all files in the current directory to the floppy disk drive.
Note: Hidden files not copied. To copy all files including hidden files, use the xcopy command.
copy autoexec.bat c:\windows
Copy the autoexec.bat, usually found at root, and copy it into the Windows directory; you can substitute the autoexec.bat file for any file(s).
copy win.ini c:\windows /y
Copy the win.ini file in the current directory to the Windows directory. Because this file already exists in the Windows directory it normally would prompt if you want to overwrite the file. However, with the /y switch you will not receive any prompt.
copy "computer hope.txt" hope
Copy the file “computer hope.txt” into the hope directory. Whenever you are dealing with a file or directory with a space, it must be surrounded with quotes. Otherwise, you’ll get the “Getting ‘Incorrect syntax ‘commsnd error.” error.
copy myfile1.txt+myfile2.txt
Copy the contents in myfile2.txt and combine it with the contents in myfile1.txt.
copy con test.txt
Finally, a user can create a file using the copy con command as shown above, which creates the test.txt file. Once you type in the above command, a user could type in whatever he or she wishes. When you have completed creating the file, you can save and exit the file by pressing Ctrl+Z, which would create ^Z, and then press Enter. Use the edit command as an easier way to view and edit files in MS-DOS.