About how to exclude copy [allyesno] From xcopy]

Source: Internet
Author: User

Author: allyesno

Team: freexploit

Date: 2006-01-14

Both xcopy and copy are commands in windows.

The advantage of xcopy is that you can exclude unnecessary files or folders for copying.

However, this command is really not easy to use. It is not as simple as the help of windows.

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

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

List of objects containing strings. Each string

It must be in a separate row of the file. If any

Absolute path of the string and the file to be copied

The file will not be copied.

For example, strings such as/obj/or. OBJ are excluded.

All files under the OBJ directory or

File with the. OBJ extension.

Next we will test

Create two folders. One is data and the other is 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 the folders marked with good and files to the backup directory, and exclude the folders and directories marked with bad.

Write the following command with xcopy help

Xcopy/e/S/H/exclude: uncopy.txt Z:/data/Z:/backup/

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

The content is as follows:

/Bad/

Bad.txt

. Bad

Xcopy/e/S/H/exclude: uncopy.txt Z:/data/Z:/backup/do you think it is wrong to execute this command first?

OK. Let's take a look.

Z:/> xcopy/e/S/H/exclude: uncopy.txt Z:/data/Z:/backup/

Invalid path

Copied 0 files

This is really interesting. The path is invalid.

Xcopy/e/S/H/exclude: uncopy.txt Z:/data/Z:/backup/the problem lies in Z:/data /.

The correct statement should be Z:/data, not Z:/backup /.

After the change, we will execute it again.

Z:/> xcopy/e/S/H/exclude: uncopy.txt Z:/Data Z:/backup/

Z:/data/Good/good.txt

Copied one file.

Let's take a look at the backup directory tree.

Z :.
└ ── Good
Good.txt

Comparison

Z :.
├ ── Bad
└ ── Good
Bad.txt
Good.txt
1. Bad
2. Bad
3. Bad
5. Bad
4. Bad

We successfully copied the folder marked with good and the file.

This is a good practice. For example, if the file on your hard disk is damaged, you can use this method to avoid the damaged file.

Or avoid unnecessary files, just copy what you want.

You can try this method when the wildcard character is not easy to use.

THX: 10 important help for this test

Allyesno was edited on

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.