I am trying to xcopy specific folders from some directory to another folder, problem is i don't want to copy all the folders but i want specific folders. E.g. DirectorySource has folders (folderA,folderB,folderC) but i want to copy folderA and folderB only to DirectoryDestination.
Asked
Active
Viewed 5,676 times
0
-
Are there so many of them, that you cannot copy them explicitly (i.e. `xcopy src\a dest /E`, `xcopy src\b dest /E`, etc.)? Otherwise look into the `/EXCLUDE` option of `xcopy`. – Christian.K Jul 20 '12 at 06:48
-
i don't think you can use xcopy to specifically copy a number of sources to 1 destination - except if you'd go the other way around and exclude the directories you don't want. But that may be exhausting too if there are many directories to be excluded. Maybe you could consider using a tool like midnight commander or even some synchronisation tool for a job like this. If it has to be console, you might want to write a batch file and define the sources in an array so you can loop through it using xcopy on each item of the array. – Ingo Jul 20 '12 at 06:52
1 Answers
0
Create a text file, say C:\excludes.txt
with the following contents:
DirectorySource\folderC\
then you can copy:
xcopy DirectorySource DirectoryDestination /s /i /exclude:C:\excludes.txt
The file excludes.txt contains a list of strings, one per line. If a file or directory matches that string, then it will not be copied. If you want to exclude folder, it is safer to use the above string instead of simply folderC
, which might skip a file called folderC_listing.txt

Hai Vu
- 37,849
- 11
- 66
- 93