xcopy is copy extension, you can copy the specified directory files and directory structure, but cannot copy system files, use the source drive, source destination pathname, source file name at least one, select/s when the source directory and all the files under the subdirectory copy. Unless you specify the/e parameter,/s does not copy an empty directory, and if you do not specify the/s parameter, xcopy copies only the files of the source directory itself, not the subdirectories below it, and when you choose the/v parameter, the sectors of the copy are compared, but the speed is reduced.
We can not ancestors, the study is to learn, should not forget or can not forget, especially DOS batch processing commands, in the development of software or projects, are inseparable from these basic original commands. In this paper, we will study the parameters and examples of xcopy
First, the Xcopy parameter introduction
Command format: XCOPY source [destination] a bunch of optional parameters
Parameter introduction
SOURCE specifies the file to be copied.
destination Specifies the location and/or name of the new file.
/a copies only the files with the archive attribute set, but does not change the properties.
/M copies only files that have an archive attribute set and closes the archive attribute.
/d:m-d-y copy files that change after a specified date or a specified date. If no date is provided, only those files that have the source time newer than the target time are copied.
/EXCLUDE:FILE1[+FILE2][+FILE3] ...
Specifies a list of files that contain strings. If any string matches the absolute path of the file to be copied, the file will not be copied.
For example, specifying a string such as \obj\ or. obj excludes all files under directory obj or files with an. obj extension.
/P prompt before creating each target file.
/S Copy directories and subdirectories, except empty.
/e copies directories and subdirectories, including empty. Same as/s/e. Can be used to modify/T.
/v validates each new file.
/w prompts you to press the key before copying.
/C Continue copying even if there is an error.
/I if the target does not exist and more than one file is copied, the target must be a directory.
/q does not display the file name when copying.
/F Displays the full source and destination file names when copying.
/L Displays the files to be copied.
/g allows files that are not encrypted to be copied to targets that do not support encryption.
/h also copies hidden and system files.
/R overwrites read-only files.
/T Creates a directory structure, but does not copy files. Empty directories or subdirectories are not included. /T/E includes empty directories and subdirectories.
/U copies only files that already exist in the target.
/k Copy Properties. General Xcopy resets the read-only property.
/n is copied with the generated short name.
/o copies file ownership and ACL information.
/x Copies the file audit settings (implied/O).
/y Suppresses the prompt to confirm overwriting an existing target file.
/-y causes the prompt to confirm overwriting an existing target file.
/z copies network files in restart mode.
Second, the Xcopy command example introduction
① an instance of a native copy of a file or folder
Xcopy d:\UpdateFiles e:\123/s/e/y
Command explanation: Copy all of the contents contained in the Updatefiles folder of the D drive to the 123 folder on the E drive;/s/e/y parameter description: When copying files, also copy empty directories or subdirectories, if the target path already has the same file, use the Overwrite method without prompting.
Application example of ② in LAN
Xcopy \\192.168.0.168\UpdateFiles e:\123/s/e/y
Command explanation: Will 192.168.0.168 this computer name is updatefiles in the folder of all things, all copied to the local e:\123 folder; parameter description: Copy the file as well as the empty directory or subdirectory, if the target path already has the same file, Use the override method without prompting.
③ with the/d tag, which enables copying only new files than the target file
If now all the files under the C:\a folder are the same as the files under D:\a (modified date and content)
A file under C:\a has been modified by someone else or added a file!
Can you write a bat to determine the last modification date for each file under the C:\a folder is not in the first two days! If it is, it is copied to the appropriate directory under D:\A (if it is, overwrite it), if not, it is not copied.
@echo off
echo y|xcopy c:\a/d/e/r/k d:\a\
Pause
Tested if the destination file is the same as the source file, it is not copied. To a certain extent, reduce the read and write to the hard disk.
xcopy command parameters