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 analyze excluding copy in xcopy

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article will explain in detail how to analyze the exclusion of copy in xcopy. The content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.

But this command is really not easy to use, and it's not as simple as windows's help. Let's explain it in detail below.

Let's take a look at how xcopy's help is written.

/ EXCLUDE:file1 [+ file2] [+ file3]...

Specifies a list of files that contain strings. Every string

Must be on a separate line of the file. If there is any

The absolute path between the string and the file to be copied

Match, that file will not be copied.

For example, specifying a string such as\ obj\ or .obj excludes

All files under the directory obj or with

The file with the .obj extension.

Let's do an experiment next.

Create two folders, one called data and one called backup

Directory tree

Z:.

├─ data

│ ├─ bad

│ └─ good

│ bad.txt

│ good.txt

│ 1.bad

│ 2.bad

│ 3.bad

│ 5.bad

│ 4.bad

└─ backup

Our goal is to copy all folders and files marked good into the backup directory and exclude folders and directories marked bad.

Write the following command with the help of xcopy

Xcopy / e / s / h / exclude:uncopy.txt z:\ data\ z:\ backup\

Uncopy.txt contains the files and folders that we want to exclude.

The contents are as follows

\ bad\

Bad.txt

.bad

Xcopy / e / s / h / exclude:uncopy.txt z:\ data\ z:\ backup\ is it wrong for everyone not to execute this command yet?

Ok, let's check it out.

Z:\ > xcopy / e / s / h / exclude:uncopy.txt z:\ data\ z:\ backup\

Invalid path

0 files were copied

That's interesting. Ah, ha, ha. Invalid path.

Xcopy / e / s / h / exclude:uncopy.txt z:\ data\ z:\ backup\ problem lies in z:\ data\

The correct way to write it should be z:\ data, do not\, and the following z:\ backup\ is OK.

We will implement it after the change.

Z:\ > xcopy / e / s / h / exclude:uncopy.txt z:\ data z:\ backup\

Z:\ data\ good\ good.txt

1 file was copied

Take a look at backup's directory tree.

Z:.

└─ good

Good.txt

Contrast

Z:.

├─ bad

└─ good

Bad.txt

Good.txt

1.bad

2.bad

3.bad

5.bad

4.bad

We successfully copied the folders and files marked only good

This is a good use, for example, if you have a file on your hard drive that is damaged, you can use this method to avoid the damaged file.

Or avoid some unneeded files and only what copy wants.

You can try this method when wildcards don't work.

Thx:10 's important help to this test

On how to analyze the exclusion of copy in xcopy to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

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