# Having a Syntax Problem with Robocopy



## bradacus (Sep 27, 2008)

This line below is included inside a batch file for backups -

robocopy "\\Xserver\d$\" "F:\HTV Data Vault\Servers\X Server\Data Drive D" /E /ZB /COPYATS /NP /w:30 /r:13 >> "F:\HTV Data Vault\Backup Log Files\server.txt"

Now when I run the batch I get this error -

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

Started : Wed May 13 11:26:23 2009

Source - \\Xserver\d$" F:\HTV 
Dest - F:\HTV Data Vault\Servers\Data
Files : 
Options : /COPYAT /R:1000000 /W:30

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

ERROR : Invalid Parameter #3 : "Vault\Servers\X"

I have another line of code that gives a similar error....

YET - when I run this line below in the batch file it works perfectly-

robocopy "\\Xserver\c$\Documents and Settings\All Users\Desktop" "F:\HTV Data Vault\Servers\X Server\Desktop" /E /ZB /COPYATS /NP /w:30 /r:13 >> "F:\HTV Data Vault\Backup Log Files\server.txt"

I am at a loss here as to why robocopy isn't processing my line correctly.

Can anyone help me on this?


----------



## TheOutcaste (Aug 8, 2007)

bradacus said:


> robocopy "\\Xserver\d$*\*" "F:\HTV Data Vault\Servers\X Server\Data Drive D" /E /ZB /COPYATS /NP /w:30 /r:13 >> "F:\HTV Data Vault\Backup Log Files\server.txt"
> 
> Now when I run the batch I get this error -
> 
> ...


The \ after d$ is the problem. Robocopy expects another folder name in the source path. It takes the 'quote space' as the start of the folder name. The next " terminates the leading quote. It then reads up to the next space to terminate the source path producing the source you see in the Error.
At least it seems like that's what it is doing.

so use this instead:

```
robocopy "\\Xserver\d$" "F:\HTV Data Vault\Servers\X Server\Data Drive D" /E /ZB /COPY:DATS /NP /w:30 /r:13 >> "F:\HTV Data Vault\Backup Log Files\server.txt"
```
HTH

Jerry


----------



## bradacus (Sep 27, 2008)

Thanks Jerry that fixed the issue.

While I have you here...do you know the switch to only show new/extra files when writing out to log? Instead of listing every file. It makes the log extremely long and not very effective for what it will be used for.

Thanks again!


----------



## TheOutcaste (Aug 8, 2007)

Don't know of anyway to limit the log file in that way.
With the switches you are using, it will copy Changed, New, Newer, and Older files. It won't copy Extra files, but Extra files are included in the log.

You could pipe this through Findstr to remove Changed, Newer and Older files so they won't appear in the log. Or process the log afterwards into a 2nd log that will contain only those entries. This way you would still have a complete log.
Makes for a long line, so using variables might make it easier to read.
This will let every line except those starting with Newer, Changed, or Older go into the log file.

```
:: Next line is a single tab character followed by 4 spaces. This must be manually entered, you can't copy off the web
Set _TS=
Set _Source=\\Xserver\d$
Set _Dest=F:\HTV Data Vault\Servers\X Server\Data Drive D
Set _Log=F:\HTV Data Vault\Backup Log Files\server.txt
robocopy "%_Source%" "%_Dest%" /E /ZB /COPY:DATS /NP /w:30 /r:13|Findstr /B /V /I /C:"%_TS%Newer" /C:"%_TS%Older" /C:"%_TS%Changed">>"%_Log%"
```
Test with sample log files. You can add the /L switch so robocopy will only list files and not actually copy for testing.

HTH

Jerry


----------

