Copies files and directory trees. XCOPY is similar to the COPY command except that it has many more switches that allow considerable control over exactly what is copied when using wildcards..
| source | The file(s) to be copied. Although this must be a single parameter, it may include multiple files specified using wildcards (* or ?). |
| destination | The location and/or name(s) of new files.
If destination is omitted, the files are copied to the current directory.
If destination refers to a directory that does not exist, the directory is created.
If destination is not an existing directory and could be a file or directory (ie. does not end with a backslash (\)), you are prompted to specify whether destination is a file or directory.
|
| Scope: | By default, XCOPY will confine its operation to files in the source directory. |
| /E | Copies the complete subdirectory structure of source and all files therein. |
| /S | Copies the complete subdirectory structure of source and all files therein but does not copy empty subdirectories. |
| /T | Copies the subdirectory structure of source but does not copy any files and does not copy empty subdirectories. To include empty subdirectories, use with the /E switch.
|
| Filters and Attributes: | By default: XCOPY will not copy files which have 'system' or 'hidden' attributes set;
copies of 'read-only' files do not have the read-only attribute set, and
all copied files have their 'archive' attribute set. . |
| /A | Only copies files with the archive attribute set (ie. files that have not been "archived" using xcopy, msbackup, etc.). |
| /M | Only copies files with the archive attribute set, turning off the archive attribute of the source files. |
| /H | Includes files with hidden and system attributes set. |
| /K | Copies files without resetting the read-only attribute, if set. |
| /R | Overwrites read-only files. |
| /U | Only copies files in source that already exist in destination. Can be used with /D to update files with more recent versions. This switch has a bit of a bug - see Note 5 below. |
| /D:date | Only copies files with a 'creation date' the same as, or later than, date.
If date is not specified, all files are copied except for same-named files in the destination directory that have a more recent 'creation date' than the one in source.
Note that dates after 2000 must include the full year (01 is read as 1901, not 2001).
The format for date depends on the COUNTRY setting being used. (For US it is mm/dd/yy(yy))
|
| Prompts | By default, XCOPY prompts before overwriting files in destination with files in source of the same name (note: this default can be modified using the COPYCMD environment variable - see SET). XCOPY also prompts for instructions if there is ambiguity whether destination is a directory or file. An ambiguity is seen when destination does not refer to an existing directory or end in a " \ ". Note that a destination of 'name.ext' could be either a file or a directory. |
| /I | Forces destination to be treated as a directory. The file/directory prompt is suppressed. |
| /Y | Overwrites existing files without prompting. |
| /-Y | Prompts before overwriting existing files.(This is the natural default, and overwrites any changes via the COPYCMD environmental variable |
| /W | Displays a prompt before starting to copy files. |
| /P | Prompts for confirmation before creating each destination file. |
| /F | The /F switch is specified as "Displays full source and destination file names while copying" but actually does nothing. |
| /Q | Does not display file names or any other messages while copying. |
| /C | Continues copying even if errors occur.
|
| Miscellaneous |
| /L | Displays files to be copied but does not actually copy them. |
| /N | Copy using the generated short names. This is necessary when copying from a VFAT volume to a FAT volume. |
| /V | Verifies that new files are readable (does not compare with the original - see VERIFY). |