How to copy directories with spaces in the name

Angie picture Angie · Aug 19, 2012 · Viewed 109k times · Source

I am trying to use robocopy but am unable to make it work because of spaces in the directory names.
I am trying to copy 3 directories: My Documents, My Music and My Pictures to 'C:\test-backup' but want the end result to be
'C:\test-backup\My Documents'
'C:\test-backup\My Music'
'C:\test-backup\My Pictures'

My command does not work:
robocopy C:\Users\Angie C:\test-backup "My Documents" /B /E /R:0 /CREATE /NP /TEE /XJ /LOG+:"CompleteBackupLog.txt"

No matter what I do, it’s just not happening. Anybody have any suggestions or tricks?

Answer

toddk63 picture toddk63 · May 14, 2015

After some trial and error and observing the results (in other words, I hacked it), I got it to work.

Quotes ARE required to use a path name with spaces. The trick is there MUST be a space after the path names before the closing quote...like this...

robocopy "C:\Source Path " "C:\Destination Path " /option1 /option2...

This almost seems like a bug and certainly not very intuitive.

Todd K.