Copy one or more files to another location.
Syntax
COPY [options] [/A|/B] source [/A|/B] [+ source2 [/A|/B]...] [destination [/A|/B]] COPY source1 + source2.. destination [options] Key source Pathname for the file or files to be copied. /A ASCII text file, will copy up until the EOF marker. /B Binary file copy, will copy all extended characters. A binary copy is the default unless merging multiple files. /D Allow the destination file to be created decrypted. destination Pathname for the new file(s). /V Verify that the destination file, once written, can be read. No comparison with the source files occurs. /N If at all possible, create only short filenames (8.3) in the destination. This option can help when copying between disks that are formatted differently e.g NTFS and VFAT, or when archiving data to an ISO9660 CDROM. /L If source is a symbolic link copy the link to the target instead of the actual file the source link points to. /Y Suppress confirmation prompt, when overwriting files. /-Y Enable confirmation prompt, when overwriting files. /Z When this option is used, if the copy is interrupted part way through it will restart if possible and resume copying the remainder of the file on the next copy if /Z is used again. Also displays a '% complete' which counts up to 100%. /? Display help.
To combine files, specify a single file for the destination, but multiple files as the source. To specify more than one file use wildcards or list the files with a + in between each (file1+file2+file3).
When copying multiple files in this way the first file must exist or else the copy will fail, a workaround for this is:
COPY null + file1 + file2 dest1
"COPY /B ... " will copy files in binary mode.
The /A and /B options can appear in multiple locations, with different meanings depending on location.
Before any source - they will set the default mode for all source and destination files.
After a source - they will set the mode for that source.
After the destination - they will set the mode for the destination.
COPY CON filename.txt
Then type the input text followed by ^Z (Control key & Z)
The default action is to prompt on overwrite unless the command is being executed from within a batch script.
To force the overwriting of destination files use the COPYCMD environment variable:
SET COPYCMD=/Y
If the file(s) were successfully copied %ERRORLEVEL% = 0
If the file was not found or bad parameters given = 1
COPY will accept UNC pathnames.
COPY is an internal command.
Copy a file in the current folder
COPY source_file.doc newfile.doc
Copy from a different folder/directory:
COPY "C:\my work\some file.doc" "D:\New docs\newfile.doc"
Specify the source only, with a wildcard will copy all the files into the current directory:
COPY "C:\my work\*.doc"
Specify the source with a wildcard and the destination as a single file, this is generally only useful with plain text files.
COPY "C:\my work\*.txt" "D:\New docs\combined.txt"
Create an empty (zero byte) file:
COPY NUL EmptyFile.txt
Quiet copy (no feedback on screen)
COPY source_file.doc newfile.doc >nul
Copy a file, but do not overwrite if the destination file already exists, this technique only works for a single file, no wildcards:
Echo n|COPY /-y c:\demo\source_file.txt c:\dir\dest.txt
“Success seems to be connected with action. Successful men keep moving. They make mistakes, but they don’t quit” ~ Conrad Hilton
ROBOCOPY - Robust File and Folder Copy.
XCOPY - Copy files and folders.
MOVE - Move a file from one folder to another.
Q126457 - VERIFY ON, COPY /V, XCOPY /V commands do not compare data.
PowerShell equivalent: Copy-Item - Copy an item from one location to another.
Equivalent bash command (Linux): cp - Copy one or more files to another location.