An external DOS/Windows command that duplicates files and folders. The Xcopy and Copy commands are widely used by Windows programmers and power users. Xcopy handles files and folders, whereas Copy only works with files (see
copy).
The following examples copy from the root on C to the root on D:
C:\>xcopy *.* d: files only
C:\>xcopy *.* d: /s files and
folders that
are not empty
C:\>xcopy *.* d: /s /e files and
all folders
empty or not
BE PROMPTED ALL THE TIME
To be asked to verify yes or no for each file about to be copied, add
/p:
xcopy *.* d: /p
NO PROMPT IF FILE ALREADY EXISTS
To overwrite an existing file without being asked to verify, add
/y:
xcopy *.* d: /y
VERIFY THE COPY
To be extra sure the copy is correct, add the
/v switch, which compares the new file with the old one; for example:
xcopy *.* d: /v
CREATE NEW FOLDER
Xcopy can create a new folder at the same time. The following example creates the NEW folder and copies all the files from the OLD folder:
C:\OLD>xcopy *.* \new
ARCHIVING FILES
Use Xcopy's
/m switch to back up only files that have been changed since the last time they were Xcopied. This works only on files that have been Xcopied at least once before and will not work on un-Xcopied files.
When Xcopy copies a file, it resets the original file's archive bit from 1 to 0. For more on archive bits, see
Attrib. Whenever you update a file, the archive bit is set to 1. When you use the
/m switch, Xcopy copies only files with the archive bit set to 1.
The following example backs up all files onto the D drive:
xcopy *.* d: /m
ARCHIVE ONE DRIVE TO ANOTHER
The following example copies everything from the C: drive to the D: drive that has changed since the last time the files on C: were Xcopied. This includes the root and all subfolders. The
/s switch is used here in order to include all subfolders.
xcopy c:\*.* d:\ /s /m