Purpose: Copies directories, subdirectories, and files.
XCOPY copies files or groups of files to and from directories.
useful for copying data to and from a fixed disk.
The first path designation specifies the source file(s); the second path
designation specifies the target file(s). A source designation must
provided. If you do not enter a target designation, files will be copied
to the current directory.
This command provides a way to copy entire disks full of data, including
established directories and subdirectories. This command should be used
of the DISKCOPY command when you want to create a disk with identical
structures, but with a different disk format (for example, to copy all
files from a 5 1/4 inch disk to a 3 1/2 inch disk).
If the source is a directory, the directory will be copied onto the
diskette. If the source to be copied includes more than one file, the
destination files will be stored in a directory. You can add a backslash
(\) to the end of the destination filename to make it a directory.
If XCOPY does not find a directory on the destination disk that matches a
specification in the command format, the copying will stop. A message
displayed asking you to specify whether or not the destination file
specification is to be stored as a filename or a directory name.
XCOPY is a much more powerful copying command than the COPY command. It
especially useful when backing up your fixed disk. A common usage would
use the /S option along with the /D:date option to back up only the files
have been changed since the date of your last backup. If you are using
for this purpose, you will probably want to make a copy of the program
(XCOPY.EXE) in the root directory of your fixed disk (remember, when you
use the /S option, XCOPY only copies files from subdirectories found WITHIN the
After you enter the XCOPY command, the program may display
Does (filename) specify a file name or directory name on the target
(F = file, D = directory)
This means XCOPY cannot determine if you want the specified path
designation entry to be sent to a filename on the target disk or to a directory.
Some versions of DOS provide a way to avoid this prompt. It is done by
the XCOPY.EXE command to MCOPY.EXE. When using MCOPY, DOS will
check to determine if the target is a filename or a directory name and
the copy accordingly. To change the name of the command to MCOPY, enter
copy xcopy.exe mcopy.exe
Then, you can use the new MCOPY.EXE program just as you would use
The only difference is that MCOPY will automatically determine whether
target is to be a file or a directory.
If an error is encountered during the XCOPY process, the program returns
the following exit codes:
0 - Copying was completed without error
1 - No files found
2 - User terminated the copy
4 - Initialization error (not enough memory, invalid syntax, path not
5 - Copy terminated due to INT 24 error reading or writing disk
For more information about the XCOPY command, see Chapter 6, Tips for Advanced Users, in the downloadable book DOS the Easy Way.
/A - Copies only files that have been set as archive files (using the
command). The copied files will still be marked as archive files in BOTH
source and destination files.
/D:(date) - Copies only those files in the source directory that have
changed on or LATER than the specified date.
/S - Copies all files in the current directory and in any
/E - Copies subdirectories, even if they are empty. If you use this
option, you must use the /S option also.
/M - Copies the same marked archive files as specified in the /A
however, the files on the destination disk are no longer marked as
files. This switch checks the archive attribute of a file: if the
archive attribute is set to off (-A), the file will not be copied.
/P - Does not copy the file until you respond to a prompt that asks
confirm that you want the file copied. However, if you are using the /E
you will not be prompted before an empty subdirectory is copied.
/V - Each file copied is verified to be sure the file stored on the
destination disk is identical to the original on the source disk.
/W - Copies only after you respond to a prompt to begin copying (if
option is omitted, the copying begins as soon as you enter the XCOPY
press the Enter key).
/Y - Causes XCOPY to replace existing files without a confirmation
/-Y - Causes XCOPY to give you a confirmation prompt before replacing
an existing file.
To copy all files and directories (except empty directories) from drive C
to drive A, enter