Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Xcopy command parameters

2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article introduces the knowledge of "how to use Xcopy command parameters". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

XCOPY is an extension of COPY, you can copy the specified directory with files and directory structure, but not system files; specify at least one source drive letter, source destination pathname and source file name when you use / S; COPY all files in the source directory and its subdirectories when / S is selected. Unless the / E parameter is specified, / S will not copy the empty directory, if the / S parameter is not specified, XCOPY will only copy the files of the source directory itself, not involving the subdirectories under it; when the / V parameter is selected, the copied sectors will be checked, but the speed will be reduced.

1. Introduction of Xcopy parameters

Command format: XCOPY source [destination] a bunch of optional parameters

Parameter introduction

Source specifies the file to copy.

Destination specifies the location and / or name of the new file.

/ An only copies files with archived property sets, but does not change the properties.

/ M copies only files with archived property sets and closes archiving properties.

/ D:m-d-y copies files that change on or after the specified date. If no date is provided, only those files whose source time is newer than the destination 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, that file will not be copied.

For example, specifying a string such as\ obj\ or .obj excludes all files under the directory obj or files with an .obj extension.

/ P prompt before creating each target file.

/ S copies directories and subdirectories except for empty ones.

/ E copy directories and subdirectories, including empty ones. Same as / S / E. Can be used to modify / T.

/ V validate each new file.

/ W prompts you to press the key before copying.

/ C continues to copy even if there is an error.

/ I if the target does not exist and more than one file is being copied, it is assumed that the target must be a directory.

The file name is not displayed when / Q is copied.

/ F displays the full source and destination file names when replicating.

/ L displays the files to be copied.

/ G allows unencrypted files to be copied to targets that do not support encryption.

/ H also copies hidden and system files.

/ R rewrites the read-only file.

/ 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 attributes. A normal Xcopy resets the read-only property.

/ N is copied with the generated short name.

/ O copy file ownership and ACL information.

/ X copy file audit settings (implied / O).

/ Y disables prompts to confirm overwriting an existing target file.

/-Y causes a prompt to confirm that an existing target file is overwritten.

/ Z copies network files in restart mode.

2. Introduction of Xcopy command example

An instance of a file or folder copied locally by ①

The code is as follows:

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

Command explanation: copy everything contained in the UpdateFiles folder of D disk to the 123folder of E disk; / s / e / y parameter description: copy the file while also copying the empty directory or subdirectory, if the target path already has the same file, use overwrite method without prompt.

Application example of ② in Local area Network

The code is as follows:

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

Command explanation: copy everything in the 192.168.0.168 computer folder named UpdateFiles to the local e:\ 123 folder; parameter description: copy the files at the same time also copy the empty directory or subdirectory, if the target path already has the same file, use overwrite method without prompt.

③ combines the / d tag to copy only files newer than the target file.

If all the files under the c:\ a folder are the same as the files under d:\ a (date and content of modification)

A file under c:\ a has been modified or added by someone else!

Can you write a bat to determine whether the last modification date of each file in the c:\ a folder is within the last two days! If so, copy to the appropriate directory under d:\ a (overwrite if there is one), and if not, do not copy.

The code is as follows:

@ echo off

Echo y | xcopy c:\ a / d / e / r / k d:\ a\

Pause

It is tested that if the target file is the same as the source file, it will not be copied. Indeed, to a certain extent, it reduces the reading and writing of the hard drive.

This is the end of "how to use Xcopy command parameters". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report