xcopy Command parameter usage introduction _dos/bat

Source: Internet
Author: User
XCOPYis a copy extension that can copy the specified directory file and directory structure together, but not the system files, use the source letter, source destination path name, source filename, specify at least one, select/s when all files under the source directory and its subdirectories are copied. Unless the/e parameter is specified,/s does not copy the empty directory, and if the/s parameter is not specified, Xcopy copies only the files of the source directory itself, not the subdirectories below it, and when the/V parameter is selected, the slices of the copy are compared, but the speed is reduced.

We can not The Ding, the study or to learn, should not forget or can not forget, especially the DOS batch command, in the development of software or projects, are inseparable from these basic original commands. In this article, we will learn about the parameters and examples of xcopy.

I. Xcopy parameter INTRODUCTION

Command format: XCOPY source [destination] a bunch of optional parameters
parameter describes
source specifies the file to copy. The
destination Specifies the location and/or name of the new file.
/A copies only the files with the archived attribute set, but does not change the properties.
/M copies only the files that have the archived attribute set and closes the archive attribute. The
/d:m-d-y copies files that have changed after a specified date or a specified date. If no date is provided, only those files with the source time that are newer than the target time are copied.
/exclude:file1[+file2][+file3] ... The
specifies a list of files that contain strings. If there is any string that matches the absolute path of the file to be copied, that file will not be copied.
For example, specifying a string such as \obj\ or. obj excludes all files under directory obj or files with the. obj extension.
/P prompts before each target file is created.
/S replicates directories and subdirectories, except for empty. The
/e replicates directories and subdirectories, including empty. Same as/s/e. Can be used to modify/T.
/V verifies each new file. The
/w prompts you to press the key before copying.
/C Continue copying, even if there are errors.
/I if the target does not exist and more than one file is being copied, assume that the destination must be a directory.
/q does not display the file name when copying.
/F Displays the full source and destination file names when replicating.
/L Displays the files that you want to copy. The
/g allows files that are not encrypted to be copied to a target that does not support encryption. The
/h also copies hidden and system files.
/R overwrites read-only files.
/T Creates a directory structure, but does not copy files. Does not include an empty directory or subdirectories. /T/E includes empty directories and subdirectories.
/U copies only files that already exist in the target. The
/k replication properties. The general Xcopy resets the read-only property.
/n is copied with the generated short name.
/o copies file ownership and ACL information.
/x Copy file Approval settings (implied/O). The
/y Suppresses prompts to confirm overwriting an existing target file. The
/-y causes a prompt to confirm that an existing destination file is overwritten.
/z Replicates network files in restart mode.

Two, the Xcopy command example introduction

  ① an instance of a native copy file or folder

Copy Code code as follows:

Xcopy d:\UpdateFiles e:\123/s/e/y

Command explanation: Copy all the items contained in the Updatefiles folder of D disk to the 123 folder on e disk;/s/e/y Parameter Description: Copy the file at the same time also copy the empty directory or subdirectories, if the target path already has the same file, use the overlay method without prompting.

  Application example of ② in LAN

Copy Code code as follows:

Xcopy \\192.168.0.168\UpdateFiles e:\123/s/e/y

Command explanation: All items in a folder with the name Updatefiles of this computer will be 192.168.0.168, all copied to the E:\123 folder of this machine; parameter description: Copy the file at the same time also copy the empty directory or subdirectories, if the target path already has the same file, Use overlay without prompting.

③ combined with/D tags to achieve only copy of new files than target files

If all the files under the C:\a folder are now the same as those under d:\a (modification date and content)

A file under C:\a was modified by someone else or a file was added!
Can you write a bat to determine if the final 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 corresponding directory under D:\a (if it is, overwritten), and if it is not, it is not replicated.

Copy Code code as follows:

@echo off
echo y|xcopy c:\a/d/e/r/k d:\a\
Pause


Tests are not replicated if the target file is the same as the source file. To a certain extent, reduce the read and write to the hard disk.

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.