Copy - DOS/Command Prompt Reference
Copies a file(s).
copy [/D] [/V] [/N] [/Y | /-Y] [/Z] [/A | /B] <src-file> [/A | /B] [+ <src-file2> [/A | /B] [+ ...]] [<dest-file> [/A | /B]]
|<src-file>||Specifies a file name to copy from.|
|+ <src-file2> ...||Specifies the additional file name to concatenate. Use ‘+’ followed by the file name.|
Specifies a file name to copy to. If omitted, copy operation will be as follows: when multiple files (to concatenate) are specified, the files are concatenated to the first source file. When only a single file is specified, the file is copied into the current directory.
If you specify existing directory to this parameter, the file(s) will be copied into its directory.
|/A||Treats the file(s) as an ASCII text file. In ASCII text file mode, the source file(s) will be read only up to the EOF character (\x1A), and the EOF character will be appended to the end of the destination file.|
Treats the file(s) as a binary file (default behavior unless concatenation is performed).
Specifying /A or /B before all source files will affect to all (source and destination) files. To specify for each file, write /A or /B just after each file. /A or /B just after a file will affect to the following source/destination files.
|/D||[Windows NT series] Do not encrypt the destination file (decrypt). Without this option, when the source file is encrypted, the destination file will be encrypted.|
|/N||[Windows NT series] Uses short file name, if available, when copying a file with a non MS-DOS format (8dot3) file name (long file name or etc.).|
|/V||Verifies the destination file after copying whether to be written correctly.|
|/Y||Suppresses prompting to confirm whether to overwrite the destination file(s) even if it exists.|
|/-Y||Prompts to confirm whether to overwrite the destination file(s) if it exists (even if ‘/Y’ is specified to the environment variable COPYCMD).|
|/Z||[Windows NT series] Copies networked files in restartable mode. In case of failure of copying due to bad connection or etc., you can resume copying by using same file names.|
|/L||[Windows Vista or later] If the source file is a symbolic link, copies the symbolic link itself instead of the target file of the link.|
This command copies files and directories. To move instead of copy, use Move command.
If the copy source file is in the current directory, you must specify the copy destination. If omitted, an error message ‘The file cannot be copied onto itself.’ is displayed.
When multiple files are specified as source files (by using ‘+’ or wildcards), the source files are concatenated if the destination is a single file, or the source files are copied into the destination directory if the destination is a directory.
[MS-DOS, Windows 95/98/Me only] Copy command is unable to copy 0-byte files. To copy 0-byte files, use Xcopy command. In case of creating a file by using CON like following sample, entering with no characters will fail to create a file. Instead, use Type command.
copy Test.s01 /B + Test.s02 /B Test.dat /B
Creates Test.dat file by concatenating Test.s01 and Test.s02. The following command line is same as the above.
copy /B Test.s01 + Test.s02 Test.dat
copy CON save.txt
This command executes ‘copying CON (console input; key input on the prompt) to the file’, that is, ‘copying/outputting key input to the file’, causing writing the input to save.txt.
(This command is useful for creating a text file immediately. To finish input, enter Ctrl+Z (which prints ^Z) and newline. See also the ‘>’ redirection sample.)
copy /B test.txt + ,,
This syntax is special, setting the file date/time (modified date/time) of the file test.txt to the current date/time. The parameter ‘,,’ (two commas; can include spaces) represents an omission of the destination file.