Xcopy: Deprecated Robo
Xcopy: Deprecated Robo
Copy files and/or directory trees to another folder. XCOPY is similar to the COPY
command except that it has additional switches to specify both the source and
destination in detail.
Xcopy has been deprecated under Vista and Windows 2008, this means that while
still available now it might disappear in a future OS release. To ensure your scripts
are 'future proof' use other tools (such as Robocopy) instead of xcopy.
XCOPY is particularly useful when copying files from CDROM to a hard drive, as it
will automatically remove the read-only attribute.
Syntax
XCOPY source [destination] [options]
Key
source : Pathname for the file(s) to be copied
(accepts wildcards).
Source Options
/D:mm-dd-yyyy
Copy files changed on or after the specified date.
If no date is given, copy only files whose
source date/time is newer than the destination time.
/EXCLUDE:file1[+file2][+file3]...
The files can each contain one or more full or
partial pathnames to be excluded.
When any of these match any part of the absolute path
of a SOURCE file, then
that file will be excluded.
For example, specifying a string like \obj\ or .obj
will exclude
all files underneath the directory obj or all files
with the
.obj extension respectively.
Copy Options
Destination Options
To always overwrite destination files use the COPYCMD environment variable: SET
COPYCMD=/Y
When comparing Dates/Times the granularity (the finest increment of the timestamp)
is 2 seconds for a FAT volume and 0.1 microsecond for an NTFS volume.
In most cases copying a single file is best done with the COPY command. When
copying a single file with XCOPY, there is no option to indicate if the destination is a
filename or a directory (with the filename defaulting to that of the source file).
In such cases XCOPY will prompt with a (locale specific) message like:
Does example.txt specify a file name
or directory name on the target
(F = file, D = directory)?
Attempting to XCOPY a source file that has a pathname longer than the Windows
maximum path length (254 characters) will result in a rather misleading 'Insufficient
Memory' error, the operation will then halt. This bug which has been around for over
10 years makes XCOPY a poor choice for any kind of backup script,
use ROBOCOPY instead.
Examples:
Copy a file:
Copy a folder: