This question already has an answer here:
-
/exclude in xcopy just for a file type
4 answers
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
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.
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
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
The exclude parameter specifies a file containing a list of files to exclude, one per line.
Xcopy command