how to use space within pathname for Window's Robocopy

1

When my path for robocopy has a space, I surround it with " but get the weird error below...

My .bat file contains:

rem Backup scans
ROBOCOPY "C:\Users\doug\Documents\My Scans\"  "B:\BACKUP\My Scans\"  /e /NFL /NDL

pause

AND I GET THIS ERROR:

C:\Windows\system32>rem Backup scans

C:\Windows\system32>ROBOCOPY "C:\Users\doug\Documents\My Scans\"  "B:\BACKUP\My
Scans\"  /e /NFL /NDL

-------------------------------------------------------------------------------
   ROBOCOPY     ::     Robust File Copy for Windows

-------------------------------------------------------------------------------

  Started : Thu Jun 23 19:32:29 2016

   Source : C:\Users\doug\Documents\My Scans"  B:\BACKUP\My\
     Dest : C:\Windows\system32\Scans"\

    Files : *.*

  Options : *.* /NDL /NFL /S /E /COPY:DAT /R:1000000 /W:30

------------------------------------------------------------------------------

2016/06/23 19:32:29 ERROR 123 (0x0000007B) Accessing Source Directory C:\Users\d
oug\Documents\My Scans"  B:\BACKUP\My\
The filename, directory name, or volume label syntax is incorrect.

C:\Windows\system32>pause
Press any key to continue . . .
windows-7
windows
command-line
backup
robocopy
asked on Super User Jun 24, 2016 by Doug Null • edited Jun 24, 2016 by DavidPostill

2 Answers

3

In your command ROBOCOPY "C:\Users\doug\Documents\My Scans\" "B:\BACKUP\My Scans\" /e /NFL /NDL the ending slashes are escaping the double quotes symbols. Robocopy then assumes that it's a full argument, which it then can't find. Try one of these instead:

ROBOCOPY "C:/Users/doug/Documents/My Scans/" "B:/BACKUP/My Scans/" /e /NFL /NDL
ROBOCOPY "C:\Users\doug\Documents\My Scans\\" "B:\BACKUP\My Scans\\" /e /NFL /NDL
ROBOCOPY "C:\Users\doug\Documents\My Scans" "B:\BACKUP\My Scans" /e /NFL /NDL

answered on Super User Jun 24, 2016 by Blerg
1

Remove the trailing backslashes on your source and destination.

"C:\Users\doug\Documents\My Scans" "B:\BACKUP\My Scans"

Edit: Somehow Blerg beat me to it. What he said.

answered on Super User Jun 24, 2016 by elCrash • edited Jun 24, 2016 by elCrash

User contributions licensed under CC BY-SA 3.0