xcopy Command parameter Usage introduction

Source: Internet
Author: User

DOS Batch command, is always immortal command, not only powerful, at the same time, speed is also the fastest! However, many novice learning computers, have forgotten the should not forget the batch command

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 describes
source specifies the file to be copied. The
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 the files with the archive attribute set and closes the archive properties.
/d:m-d-y copies 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] ... The
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 prompts before each target file is created.
/S copies directories and subdirectories, except for empty.
/e copies directories and subdirectories, including empty. Same as/s/e. Can be used to modify/T.
/V verifies 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 you are copying more than one file, assume that the destination must be a directory.
/q does not display the file name when copying. The full source and destination file names are displayed when
/F is copied.
/L Displays the files to be copied. The
/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. The
/k copy property. 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 prompting to confirm overwriting an existing target file.
/-y causes a 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

The code is as follows:
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

The code is as follows:

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.

The code is as follows:


@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 parameter Usage introduction

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.