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?
You can let xcopy exclude folders or files in folder while copying from one directory to another with simple steps. Likewise, you have better choice to do exclusion during file backup or file syncing with a comprehensive tool.
Using /excludeList 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.
By default, the basic xcopy command only copies files in the directory you specify as the source directory. You must use the /E option to copy subdirectories in the source directory as well.
Well, after searching I found a similar question in StackOverflow but was not so helpful for my case:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With