Xcopy with excluding folders (sub-directories)
Asked Answered
J

1

9

I want to copy files and folders in a directory to another folder excluding sub-folders with files contains it, as for example I have a large number of files for node_modules directory which like 100Mb with 50K+ files, that I don't need to copy.

I tried using xcopy like this :

xcopy . c:\inetpub\CIVEBuildCentral\UI\. /Y /S /EXCLUDE:CIVE\UI\elist.txt

and elist.txt contains :

\node_modules\

But no luck, and its really annoying syntax and I don't see its optimal to check-in such a useless file for this case.

Any idea how to solve this?

Jillian answered 28/1, 2016 at 11:47 Comment(0)
J
16

Well, after searching I found a similar question in StackOverflow but was not so helpful for my case:

  • Xcopy Command excluding files and folders ( its marked as duplicated but actually it's not really duplicated, it is the different case even if answer seemed the same way, and found no answer for my case anyway)

But I found that if you using Windows 7 or later, you can use robocopy instead, found its so powerful tool compared to old man xcopy, and no need to dirty work for exceptions, the command to achieve what I need replaced xcopy with :

robocopy . c:\inetpub\CIVEBuildCentral\UI\. /IS /S /XD node_modules

For full documentation for it, you can see this link: http://ss64.com/nt/robocopy.html

Solved my issue, and the output of the result was so nice, clear, and well formatted.

Jillian answered 28/1, 2016 at 11:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.