I am trying to use Robocopy to create client software builds by copying all the necessary files out of our main repository. We have multiple clients each needing their own custom software builds.
I have a list of requirements for each client's build. My thinking is to copy over the core stuff first (binaries and such, used by all clients) and then copy over the client specific stuff depending on for whom I'm making a build by making use of these lists. We have something like this already working with xcopy.
There is obviously a bunch of stuff I want excluded from the client build such as source files, log files and obviously all the client specific stuff. I thought by making clever use of the /xf
and /xd
switches I should be able to get it to work.
After a getting all the needed info, the following command is built in Lua
:
robocopy "Z:\path\to\source" "../dest" /e /xf *.cpp *.h *.hpp [[. . .]] *.cxx /xd Data/Testing Data/Some/Client/Data Data/Other/Client/Data [[ . . .]] Data/More/Directories
When running it I get the following output:
-------------------------------------------------------------------------------
ROBOCOPY :: Robust File Copy for Windows
-------------------------------------------------------------------------------
Started : Tuesday, August 1, 2017 11:15:59 AM
Source : Z:\path\to\source
Dest : ../dest
Files : *.*
Exc Files : *.cpp
*.h
*.hpp
[[. . .]]
*.cxx
Exc Dirs : Data/Testing
Data/Some/Client/Data
Data/Other/Client/Data
[[ . . .]]
Data/More/Directories
Options : *.* /S /E /DCOPY:DA /COPY:DAT /R:1000000 /W:30
------------------------------------------------------------------------------
The output tells me my command is formatted properly and that Robocopy understands what I'm asking it to do.
The problem is that it's straight up ignoring the Exc dirs
list and is just copying everything. I do not want to exclude the whole Data
directory, but only the bits inside it that are relevant.
If I use back slashes (\
) then the Exc dirs
output is printed like Data\\testing
. Could this be my issue?
Best Answer
robocopy
is advertised as the replacement forxcopy
but if it's unable to do something simple as what I want then it's truly a terrible replacement.Any directory name after
/xd
that matches is excluded. This makes sense and it functions as advertised. Looks like any time you give it anything more than just a directory name then it wets the bed. My problem is surely not so unique looking at some of the other people on the internet and their troubles withrobocopy
.I have the following directories:
robocopy
with/xd Data
thenC:\repo\SomeProject\Data
andC:\repo\SomeOtherProject\Data
will also be excludedrobocopy
with/xd foo bar
thenC:\repo\AnotherProject\bar
will also be excluded.I want to be able to call
robocopy
with/xd Data\foo Data\bar
so that onlyfoo
andbar
inData
will be excluded.Absolute file paths will not work because the code must be portable and I don't really want to inject absolute paths for each entry in my >100 excludes list. It just doesn't seem right.
What appears to happen is if I use
/xd Data\bar
then robocopy interprets it asData\\bar
which it cannot find. I do not know why a single\
is changed to\\
and any permutation of\
or/
does not work either.The solution
So ultimately the answer to my question is to use
xcopy
. I give it a list containing entries such as*.cpp
,8.vcxproj
,\Data\foo\
,\Data\bar
\ and a 100 other entries and it seems to work just fine excluding all the stuff I don't want while keeping the stuff I need.