Tell me more ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 except Source 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?

share|improve this question

1 Answer

up vote 4 down vote accepted
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.

share|improve this answer
Is it necessary to include quotes around Source Code in the exclusion file, or can it handle spaces ok? – dunxd Sep 22 '12 at 2:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.