XCOPY /Exclude Directory Syntax
Solution 1
C:\>xcopy /?
...
/EXCLUDE:file1[+file2][+file3]...
Specifies a list of files containing strings. Each string
should be in a separate line in the files. When any of the
strings match any part of the absolute path of the file to be
copied, that file will be excluded from being copied. For
example, specifying a string like \obj\ or .obj will exclude
all files underneath the directory obj or all files with the
.obj extension respectively.
You need to put "Source Code" in a file and specify that file on the command line.
Solution 2
I believe this error needs some further explanation. I found this blog post on the issue very informative.
Basically, you need to use the old 8.3 (DOS short filenames in the exclude path). You can determine the short names by running the command "DIR /X" from a command prompt after changing directory to the parent of the folder (you want the 8.3 name for). It's a shame MS hasn't updated this command to support long file names.
I would suggest using robocopy instead if you don't want to use short path/file names. Of course I guess you could put the long names in an external "excluded_files.txt". This does seem to be supported by XCopy.
Related videos on Youtube
Onion-Knight
Updated on September 17, 2022Comments
-
Onion-Knight almost 2 years
I'm trying to use
XCOPY
to copy a directory that looks like this:-MainFolder -ManyFoldersIWantToCopy -ManyFoldersIWantToCopy -... -Source Code
I want to use the
/EXCLUDE
option to copy every folder exceptSource Code
.I tried using the following, but I did not have any luck:
xcopy "Source" "Destination" /EXCLUDE:"\Source Code\" /E /C /R /I /K /Y
The error message I receive says:
Can't read file: "\Source Code\"
.I've tried removing the double-quotes all together, using single-quotes instead, with/without the \'s, but I get the same error message.
Any ideas?
-
dunxd almost 12 yearsIs it necessary to include quotes around Source Code in the exclusion file, or can it handle spaces ok?