I have tried to specify an
/EXCLUDE filename with spaces in it to
xcopy, but it always chokes. How can I specify such a path to
xcopy without copying the
/EXCLUDE files into the current directory and without using the old DOS
~1 shortname hack?
c:\Users\binki\Documents\repos\xcopy_exclude_spacey>dir source Volume in drive C is OS Volume Serial Number is 7C4E-86D4 Directory of c:\Users\binki\Documents\repos\xcopy_exclude_spacey\source 2013-01-03 16:39 <DIR> . 2013-01-03 16:39 <DIR> .. 2013-01-03 16:39 0 a 2013-01-03 16:39 0 a b c 2013-01-03 16:39 0 b 2013-01-03 16:39 0 c 4 File(s) 0 bytes 2 Dir(s) 117,279,027,200 bytes free c:\Users\binki\Documents\repos\xcopy_exclude_spacey>type "various exclude rules\a" a c:\Users\binki\Documents\repos\xcopy_exclude_spacey>xcopy /E /EXCLUDE:"various exclude rules\a" source dest Can't read file: "various exclude rules\a" 0 File(s) copied c:\Users\binki\Documents\repos\xcopy_exclude_spacey>xcopy /E "/EXCLUDE:various exclude rules\a" source dest Invalid number of parameters
None of the ways of quoting the filename which would work fine in a decent shell work for me with xcopy. For some reason,
"/EXCLUDE:<filename>" syntax prevents the option itself from being recognized. The other syntax,
"/EXCLUDE:"<filename>", causes the message
Can't read file: "<filename>" to be printed, showing that the option is being parsed correctly: the double-quotes are preventing the argument from being split up into multiple parts. However, this message suggests that the double-quotes are not being properly stripped from the filename by xcopy before it tries to open the file.
It seems, from this, that if the first component of the path I specify in
/EXCLUDE started with a
" and my
/EXCLUDE filename ends in
", I would be able to reference that file from xcopy’s
/EXCLUDE option successfully. But Windows refuses to let me place the
" character in my filename.
So, how do I use xcopy in a modern world with spacey filenames?