Copies files. See also MOVE, XCOPY and ROBOCOPY.
Examples:
copy F:\\File.txt
Copies the file into the current directory, assuming the current directory is not F:\\
.
copy "F:\\My File.txt"
As above; quotation marks are needed to surround a file with spaces.
copy F:\\*.txt
Copies the files located at F:\\
and ending in dot txt into the current directory, assuming the current directory is not F:\\
.
copy F:\\*.txt .
Does the same as the above command.
copy File.txt
Issues an error message, as File.txt
cannot be copied over itself.
copy File1.txt File2.txt
Copies File1.txt
to File2.txt
, overwriting File2.txt
if confirmed by the user or if run from a batch script.
copy File.txt "My Directory"
Copies File.txt
into My Directory
directory, assuming My Directory
exists.
copy Dir1 Dir2
Copies all files directly located in directory Dir1
into Dir2
, assuming Dir1
and Dir2
are directories. Does not copy files located in nested directories of Dir1
.
copy *.txt *.bak
For each *.txt
file in the current folder, makes a copy ending with bak
rather than txt
.
Links:
$ copy /?
Copies one or more files to another location.
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 and/or filename for the new file(s).
/V Verifies that new files are written correctly.
/N Uses short filename, 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 is a symbolic link, copy the link to the target
instead of the actual file the source link points to.
The switch /Y may be preset in the COPYCMD environment variable.
This may be overridden with /-Y on the command line. Default is
to prompt on overwrites unless COPY command is being executed 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).