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?
Use quotation marks when specifying long filenames or paths with spaces. For example, typing the copy c:\my file name d:\my new file name command at the command prompt results in the following error message: The system cannot find the file specified. The quotation marks must be used.
Alternatively, right-click the folder, select Show more options and then Copy. In Windows 10 and earlier versions, right-click the folder and select Copy, or click Edit and then Copy. Navigate to the location where you want to place the folder and all its contents.
The cp command also copies entire directories into other directories if you specify the -r or -R flags. You can also copy special-device files using the -R flag. Specifying -R causes the special files to be re-created under the new path name.
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.
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