5

I am using a robocopy batch file to backup my work. This is the code in my .bat file:

@echo off
cls
echo press any key to continue backup!
pause
ROBOCOPY "F:\source" "D:\destination" /s /e /xf *.sas7bdat /xd "F:\directory_to_exclude"
echo backup complete
pause

However this does not work and the log output shows that robocopy does not distinguish the destination from the source.

Source: F:\source D:\destination
Dest -
Files *.*
Files excluded: *.sas7bdat
Directories excluded: F:\directory_to_exclude
---------------------------------------------
Error: no folder destination specified

What needs to be changed in the robocopy syntax?

2 Answers 2

19

Possible problem is that your source or/and destination ends by \. So you have that sequence of characters \", and robocopy interpret it as escape sequence for literal ". You have to remove \ or double it:

ROBOCOPY "F:\source" "D:\destination"
ROBOCOPY "F:\source\\" "D:\destination\\"
1
  • Fantastic answer! I have done so much to dance around this problem for years by always using paths that didn't need quotes on them. Thank-you, thank-you, thank-you! Now the question is why isn't this noted in the Robocopy documentation.
    – Bryan C.
    Commented Feb 13, 2021 at 23:46
0

Your Robocopy output mentions both source and destination paths on the Source: line. Are you sure you quoted the command right?

I copied just the robocopy command and here is my output:

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

  Started : Thursday, March 26, 2015 9:48:44 AM
   Source - F:\source\
     Dest - D:\destination\

    Files : *.*

Exc Files : *.sas7bdat

 Exc Dirs : F:\directory_to_exclude

  Options : *.* /S /E /DCOPY:DA /COPY:DAT /R:1000000 /W:30

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

When I (double)quote the source and destination wrong I get the following result (like yours):

   Source - F:\source D:\destination\
3
  • My bat file uses " as quotation marks. Changing them to 'does not work either and lists the source as F:\ F:\source\'` and destination as F:\ D:\destination\'` and fails because it can't find these directories as they don't exist. Commented Mar 26, 2015 at 9:04
  • If your source folder is called source and if your destination folder is actually called destination try to remove the quotation marks since there are no spaces in the foldernames.
    – Lambert
    Commented Mar 26, 2015 at 9:07
  • Thanks, spaces exist in the real folder names but adding a double slash as PetSerAl mentions solves the problem. Commented Mar 26, 2015 at 9:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .