Search code examples
robocopy

Robocopy Invalid Parameter #7 Log


I've been cracking my head trying to fix this. But it seems this command line isn't working for my robocopy batch file. It has something to do with the parameters, quotation marks, backslashes or maybe I'm just blind. I'm not too sure. Here's the code.

REM @Echo Off
SETLOCAL EnableDelayedExpansion
Set hostname=%COMPUTERNAME%

set torun=wmic bios get serialnumber /format:value
for /f "tokens=2 delims==" %%a in ('%torun%') do set serial=%%a

Set src="D:\BackUPTEST\%serial%"
set dest="D:\RestoreTEST\%serial%"
set logdest="D:\RestoreTEST\%serial%\Logs"

set logfile=Restore-%serial%.log
set log="%logdest%\%logfile%"

robocopy %src% %dest% /E /R:3 /W:3 /TEE /log:%log% /NP

echo Restore Completed. . .
ENDLOCAL
Echo On

I'm returned with...

ERROR : Invalid Parameter #7 : "/log:D:\RestoreTEST\CNU1293K2J\Logs\Restore-CNU1293K2J.log"

   Simple Usage :: ROBOCOPY source destination /MIR

         source :: Source Directory (drive:\path or \\server\share\path).
    destination :: Destination Dir  (drive:\path or \\server\share\path).
           /MIR :: Mirror a complete directory tree.

For more usage information run ROBOCOPY /?

**** /MIR can DELETE files as well as copy them !


Solution

  • Okay, figured out. As for Logging, there should be an existing Folder. So I simply added mkdir %logdest% before the robocopy command initializes... That seems to fix it.