Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xcopy /exclude issue

I am trying to run xcopy that copies files excluding .obj, etc. What I am seeing is that Microsoft.Practices.ObjectBuilder.dll is not copied when my excludes.txt file contains .obj as an extension. When .obj is removed, I Microsoft.Practices.ObjectBuilder.dll is copied correctly. This does not happen to other dlls though.

Does anyone have any idea why this would happen?

Thanks!

Lenik

like image 206
Lenik Avatar asked Aug 15 '26 09:08

Lenik


2 Answers

Yeah, xcopy is dumb like that.

Do this:

dir /b *.obj >excludes.txt
xcopy * /exclude:excludes.txt targetdir

although this will still have the problem sometimes.

If you had a file called practices.obj, for example, it wouldn't copy that, but it would also fail to copy your Microsoft.Practices.ObjectBuilder.dll

A handy trick is if you specify /s on dir, you get recursion and the full path, then if you specify the source directory fully on the xcopy, the excludes will have to match from the beginning:

dir /s /b *.obj >excludes.txt
xcopy c:\sourcedir\* /exclude:excludes.txt \targetdir

Now Microsoft.Practices.ObjectBuilder.dll would only fail to copy if you happen to have a Microsoft.Practices.obj file in the same directory. Get it?

like image 103
Hafthor Avatar answered Aug 16 '26 23:08

Hafthor


I guess because the substring .obj is found in the name Microsoft.Practices**.Obj**ectBuilder.dll and since windows is not case sensitive, it will exclude it.

like image 26
André Avatar answered Aug 16 '26 22:08

André



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!