XCOPY
Type: External (3.2 and later)
Syntax:
XCOPY [d:][path]filename [d:][path][filename] [/A][/D:(date)]
[/E][/M][/P]
[/S][/V][/W][Y|-Y]
Purpose: Copies directories, subdirectories, and files.
Discussion
XCOPY copies files or groups of files to and from directories.
Especially
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
always be
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
all
established directories and subdirectories. This command should be used
instead
of the DISKCOPY command when you want to create a disk with identical
file
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
destination
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
PATH
specification in the command format, the copying will stop. A message
will be
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
is
especially useful when backing up your fixed disk. A common usage would
be to
use the /S option along with the /D:date option to back up only the files
that
have been changed since the date of your last backup. If you are using
XCOPY
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
current
directory).
After you enter the XCOPY command, the program may display
Does TST 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.
NOTE:
Some versions of DOS provide a way to avoid this prompt. It is done by
renaming
the XCOPY.EXE command to MCOPY.EXE. When using MCOPY, DOS will
automatically
check to determine if the target is a filename or a directory name and
carry out
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
XCOPY.EXE.
The only difference is that MCOPY will automatically determine whether
the
target is to be a file or a directory.
If an error is encountered during the XCOPY process, the program returns
one of
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
found)
5 - Copy terminated due to INT 24 error reading or writing disk
For more information on using the XCOPY command, refer to Chapter 6, Tips
for
Advanced Users.
Options
/A - Copies only files that have been set as archive files (using the
ATTRIB
command). The copied files will still be marked as archive files in BOTH
the
source and destination files.
/D:(date) - Copies only those files in the source directory that have
been
changed on or LATER than the specified date.
/S - Copies all files in the current directory and in any
subdirectory
within it.
/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
option;
however, the files on the destination disk are no longer marked as
archive
files. This switch checks the archive attribute of a file: if the
file`s
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
you to
confirm that you want the file copied. However, if you are using the /E
option,
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
this
option is omitted, the copying begins as soon as you enter the XCOPY
command and
press the Enter key).
/Y - Causes XCOPY to replace existing files without a confirmation
prompt.
/-Y - Causes XCOPY to give you a confirmation prompt before replacing
an
existing file.
Example
To copy all files and directories (except empty directories) from drive C
to
drive A, enter
xcopy c: a: /s
Back to the
Easy DOS
Command Index