XCOPY
Xcopy Copies files and directories, including subdirectories.
Syntax
xcopy Source [Destination] [/w] [/p] [/c] [/v] [/q] [/f] [/l] [/g] [/d[:mm-dd-yyyy]]
[/u] [/i] [/s [/e]] [/t] [/k] [/r] [/h] [{/a|/m}] [/n] [/o] [/x] [/exclude:file1[+[file2]][+[file3]]
[{/y|/-y}] [/z]
Parameters
Source
Required. Specifies the location and names of the files you want to copy.
This parameter must include either a drive or a path.
Destination
Specifies the destination of the files you want to copy. This parameter
can include a drive letter and colon, a directory name, a file name, or
a combination of these.
/w
Displays the following message and waits for your response before starting
to copy files:
Press any key to begin copying file(s)
/p
Prompts you to confirm whether you want to create each destination file.
/c
Ignores errors.
/v
Verifies each file as it is written to the destination file to make sure
that the destination files are identical to the source files.
/q
Suppresses the display of xcopy messages.
/f
Displays source and destination file names while copying.
/l
Displays a list of files that are to be copied.
/g
Creates decrypted destination files.
/d[:mm-dd-yyyy]
Copies source files changed on or after the specified date only. If you
do not include a mm-dd-yyyy value, xcopy copies all Source files that
are newer than existing Destination files. This command-line option allows
you to update files that have changed.
/u
Copies files from Source that exist on Destination only.
/i
If Source is a directory or contains wildcards and Destination does not
exist, xcopy assumes destination specifies a directory name and creates
a new directory. Then, xcopy copies all specified files into the new directory.
By default, xcopy prompts you to specify whether Destination is a file
or a directory.
/s
Copies directories and subdirectories, unless they are empty. If you omit
/s, xcopy works within a single directory.
/e
Copies all subdirectories, even if they are empty. Use /e with the /s
and /t command-line options.
/t
Copies the subdirectory structure (that is, the tree) only, not files.
To copy empty directories, you must include the /e command-line option.
/k
Copies files and retains the read-only attribute on destination files
if present on the source files. By default, xcopy removes the read-only
attribute.
/r
Copies read-only files.
/h
Copies files with hidden and system file attributes. By default, xcopy
does not copy hidden or system files.
/a
Copies only source files that have their archive file attributes set.
/a does not modify the archive file attribute of the source file. For
information about how to set the archive file attribute by using attrib,
see Related Topics.
/m
Copies source files that have their archive file attributes set. Unlike
/a, /m turns off archive file attributes in the files that are specified
in the source. For information about how to set the archive file attribute
by using attrib, see Related Topics.
/n
Creates copies by using the NTFS short file or directory names. /n is
required when you copy files or directories from an NTFS volume to a FAT
volume or when the FAT file system naming convention (that is, 8.3 characters)
is required on the destination file system. The destination file system
can be FAT or NTFS.
/o
Copies file ownership and discretionary access control list (DACL) information.
/x
Copies file audit settings and system access control list (SACL) information
(implies /o).
/exclude:filename1[+[filename2]][+[filename3]]
Specifies a list of files containing strings.
/y
Suppresses prompting to confirm that you want to overwrite an existing
destination file.
/-y
Prompts to confirm that you want to overwrite an existing destination
file.
/z
Copies over a network in restartable mode.
/?
Displays help at the command prompt.
Remarks
Using /v
Windows XP does not use this command. It is accepted only for compatibility
with MS-DOS files.
Using /exclude
List each string in a separate line in each file. If any of the listed
strings match any part of the absolute path of the file to be copied,
that file is then excluded from the copying process. For example, if you
specify the string "\Obj\", you exclude all files underneath
the Obj directory. If you specify the string ".obj", you exclude
all files with the .obj extension.
Using /z
If you lose your connection during the copy phase (for example, if the
server going offline severs the connection), it resumes after you reestablish
the connection. /z also displays the percentage of the copy operation
completed for each file.
Using /y in
the COPYCMD environment variable
You can use /y in the COPYCMD environment variable. You can override this
command by using /-y on the command line. By default, you are prompted
to overwrite, unless you run copy from within a batch script.
Copying encrypted files
Copying encrypted files to a volume that does not support EFS results
in an error. Decrypt the files first or copy the files to a volume that
does support EFS.
Appending files
To append files, specify a single file for destination, but multiple files
for source (that is, by using wildcards or file1+file2+file3 format).
Examples
To copy all the files and subdirectories (including any empty subdirectories)
from drive A to drive B, type:
xcopy a: b: /s /e
To include any system or hidden
files in the previous example, add the/h command-line option as follows:
xcopy a: b: /s /e /h
To update files in the \Reports
directory with the files in the \Rawdata directory that have changed since
December 29, 1993, type:
xcopy \rawdata \reports
/d:12-29-1993
To update all the files that
exist in \Reports in the previous example, regardless of date, type:
xcopy \rawdata \reports
/u
To obtain a list of the files
to be copied by the previous command (that is, without actually copying
the files), type:
xcopy \rawdata \reports /d:12-29-1993
/l > xcopy.out
The file Xcopy.out lists every
file that is to be copied.
To copy the \Customer directory
and all subdirectories to the directory \\Public\Address on network drive
H:, retain the read-only attribute, and be prompted when a new file is
created on H:, type:
xcopy \customer h:\public\address
/s /e /k /p
|