But this command is really hard to use, not as simple as Windows Help.
Let's see how Xcopy's Help is written first.
/EXCLUDE:FILE1[+FILE2][+FILE3] ...
Specifies a list of files that contain strings. Each string
Must be in a separate line of the file. If there is any
The absolute path to 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 directory obj or with
The file for the. obj extension.
Now let's do the experiment.
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 exclude folders and directories that have been labeled bad, with folders and files that have been marked good, and file copy to the backup directory.
Write the following command according to Xcopy's help
xcopy/e/s/h/exclude:uncopy.txt z:\data\ z:\backup\
Uncopy.txt contains the files and folders we want to exclude.
The contents are as follows
\bad\
Bad.txt
. Bad
xcopy/e/s/h/exclude:uncopy.txt z:\data\ z:\backup\ This order, do you think it's wrong to do it first?
OK, let's do a look.
z:\>xcopy/e/s/h/exclude:uncopy.txt z:\data\ z:\backup\
Invalid path
0 files were copied
That's funny, huh? Invalid path
xcopy/e/s/h/exclude:uncopy.txt z:\data\ z:\backup\ The problem is above z:\data\.
The correct writing should be z:\data do not \ and the back of the z:\backup\ will not \ All can
We'll do it again after we've changed.
z:\>xcopy/e/s/h/exclude:uncopy.txt Z:\data z:\backup\
Z:\data\good\good.txt
1 files were copied
Look at the directory tree of Backup
Z:.
└─good
Good.txt
Contrast
Z:.
├─bad
└─good
Bad.txt
Good.txt
1.bad
2.bad
3.bad
5.bad
4.bad
We have successfully replicated folders and files that have only good marked
This is a good use, for example, you have a damaged file on your hard drive. You can use this method to avoid corrupted files
Or avoid some unwanted files, copy what you want.
You can try this way if the wildcard doesn't work.
Thx:10 's important help for this test
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.