xcopy
Copies files and directory trees.
XCOPY [source] [destination] [/switches]
Options
source
Specifies the directory and/or name of file(s) to copy.
destination
Specifies the location and/or name of new file(s).
/A
Copies only files with the archive attribute set and doesn't
change the attribute.
/C
Continues copying even if errors occur.
/D[:M/D/Y]
Copies only files which have been changed on or after the
specified date. When no date is specified, only files which are
newer than existing destination files will be copied.
/E
Copies any subdirectories, even if empty.
/F
Display full source and destination name.
/H
Copies hidden and system files as well as unprotected files.
/I
If destination does not exist and copying more than one file,
assume destination is a directory.
/L
List files without copying them. (simulates copying)
/M
Copies only files with the archive attribute set and turns off
the archive attribute of the source files after copying them.
/N
Suppresses prompting to confirm you want to overwrite an
existing destination file and skips these files.
/P
Prompts for confirmation before creating each destination file.
/Q
Quiet mode, don't show copied filenames.
/R
Overwrite read-only files as well as unprotected files.
/S
Copies directories and subdirectories except empty ones.
/T
Creates directory tree without copying files. Empty directories
will not be copied. To copy them add switch /E.
/V
Verifies each new file.
/W
Waits for a keypress before beginning.
/Y
Suppresses prompting to confirm you want to overwrite an
existing destination file and overwrites these files.
/-Y
Causes prompting to confirm you want to overwrite an existing
destination file.
Notes
The switch /Y or /N may be preset in the COPYCMD environment variable.
This may be overridden with /-Y on the command line.
set COPYCMD=/Y
To cancel the /Y for a particular xcopy command, use /-Y at the command line.
The COPYCMD variable also affects the copy command.
Use /Y to change the way both copy and xcopy behave.
Use /N, which copy ignores, to change only the way xcopy behaves.
XCOPY may be used to determine if a drive is valid in a batch file.
XCOPY %drive%\NUL /L >NUL
if NOT ERRORLEVEL 5 goto invaliddrive
XCOPY may be used to determine if the destination drive is full in a batch file.
XCOPY %drive1%\%dir% %drive1%\%dir% /S
if ERRORLEVEL 39 goto destinationfull
See Also
Copy
Diskcopy
Copyright © 2009 Stephan Peters
This file is derived from XCOPY v1.3 by Rene Ableidinger (patches 2005: Eric Auer).
See the file H2Cpying.txt for copying conditions.