Xcopy Command excluding files and folders [duplica

2019-02-12 07:00发布

This question already has an answer here:

I want to copy files and folders in a directory to another folder excluding a list of files and folders.Is that possible.

I was just trying to copy excluding file :

 xcopy c:\t1 c:\t2 /EXCLUDE:exclusion.txt

But it keeps saying read cant read file : exclusion.txt

Can anyone help me on this?

Thanks

4条回答
仙女界的扛把子
2楼-- · 2019-02-12 07:41

The exclude parameter specifies a file containing a list of files to exclude, one per line.

Xcopy command

查看更多
相关推荐>>
3楼-- · 2019-02-12 07:52

It is same as above answers, but is simple in steps

c:\SRC\folder1

c:\SRC\folder2

c:\SRC\folder3

c:\SRC\folder4

to copy all above folders to c:\DST\ except folder1 and folder2.

step1: create a file c:\list.txt with below content, one folder name per one line

folder1\

folder1\

step2: Go to command pompt and run as below xcopy c:\SRC*.* c:\DST*.* /EXCLUDE:c:\list.txt

查看更多
爷、活的狠高调
4楼-- · 2019-02-12 07:58

Just give full path to exclusion file: eg..

-- no - - - - -xcopy c:\t1 c:\t2 /EXCLUDE:list-of-excluded-files.txt

correct - - - xcopy c:\t1 c:\t2 /EXCLUDE:C:\list-of-excluded-files.txt

In this example the file would be located " C:\list-of-excluded-files.txt "

or...

correct - - - xcopy c:\t1 c:\t2 /EXCLUDE:C:\mybatch\list-of-excluded-files.txt

In this example the file would be located " C:\mybatch\list-of-excluded-files.txt "

Full path fixes syntax error.

查看更多
Juvenile、少年°
5楼-- · 2019-02-12 08:02

Like Andrew said /exclude parameter of xcopy should be existing file that has list of excludes.

Documentation of xcopy says:

Using /exclude

List each string in a separate line in each file. If any of the listed strings match any part of the absolute path of the file to be copied, that file is then excluded from the copying process. For example, if you specify the string "\Obj\", you exclude all files underneath the Obj directory. If you specify the string ".obj", you exclude all files with the .obj extension.

Example:

xcopy c:\t1 c:\t2 /EXCLUDE:list-of-excluded-files.txt

and list-of-excluded-files.txt should exist in current folder (otherwise pass full path), with listing of files/folders to exclude - one file/folder per line. In your case that would be:

exclusion.txt
查看更多
登录 后发表回答