13

I'm trying the following command:

robocopy "x:\dir" "y:\dir" /mir /z /tee /fft /nfl /ndl /eta /log:"x:\path to logs\12-15-11 01 file with spaces.txt"

I'm getting this error:

ERROR : Invalid Parameter #10 : "/log:x:\path to logs\12-15-11 01 file with spaces.txt"

EDIT #1

Turns out that the above command was valid, I had a typo in my path. If you have a path which includes spaces you can provide them to robocopy's /log switch like so: /log:"c:\path to a file\robocopy.log"

slm
  • 7,355
  • 16
  • 54
  • 72
  • Works for me. Does it perhaps show a more detailed error at the top? – Carko Dec 15 '11 at 22:01
  • Are you running that command in the context of a script instead of directly at the command line. Perhaps something else is adding some kind of escaping? – Zoredache Dec 15 '11 at 22:09
  • The error message suggests that the initial quote marks are before rather than after the colon; are you sure the command you were trying to run is as shown? – Harry Johnston Dec 16 '11 at 03:12
  • I so sorry, I had a typo in the path. Majorily embarrassed. Thanks for everyone's prompt help! What's the procedure, should I delete this question? Or can I rephrase it and add an answer showing that you can put quotes around the argument to /log switch of robocopy? – slm Dec 16 '11 at 15:25
  • No reason to delete @slm. If one of the above comments helped you find the problem, ask them to post it as an answer, and then mark the answer correct. If the issue was something else entirely, write your own answer and mark it as the answer so future searchers will know to check that if they have a similar problem. – music2myear Dec 16 '11 at 15:32

4 Answers4

13

If you need to provide a path that includes spaces to robocopy's /log switch you can do it like this:

/log:"c:\path to logs files\some log file.txt"
slm
  • 7,355
  • 16
  • 54
  • 72
  • I get Invalid Error: parameter #11 "/log". I added it on to the end of an otherwise working command. – Andrew S Nov 14 '15 at 05:39
  • I no longer work where I support windows so have no way to test this. – slm Nov 14 '15 at 13:26
  • Make sure the log file's parent directory exists. Robocopy won't created it, and, sadly, complains about the cmdline parameter if the dir doesn't exist. – mojo Mar 26 '18 at 14:49
  • I can't get this to work. Any time a variable contains a space Robocopy breaks down. I have tried '"D:\this not working\filename.txt"', '"""D:\this not working\filename.txt"""', 'D:\this not working\filename.txt' Tried adding quotes around the variable in robocopy "$Src" "$Dest" /LOG:"$LogPath" Nothing works. What am I doing wrong? – cliffclof Aug 29 '20 at 23:16
  • Dummy me. I used robocopy D:\Source Folder\ F:\Destination Folder\. Needed to be D:\Source Folder\ F:\Destination Folder. Watch that source-destination backslash. – cliffclof Aug 29 '20 at 23:22
4

There are four way of logging as the Powershell documentation

/log:<LogFile> : Writes the status output to the log file (overwrites the existing log file).

  • e.g: robocopy "c:\a" "c:\b" /log:"c:\copy_log.log"

/log+:<LogFile> : Writes the status output to the log file (appends the output to the existing log file).

  • e.g: robocopy "c:\a" "c:\b" /log+:"c:\copy_log.log"

/unilog:<LogFile> : Writes the status output to the log file as Unicode text (overwrites the existing log file).

  • e.g: robocopy "c:\a" "c:\b" /unilog:"c:\copy_log.log"

/unilog+:<LogFile> : Writes the status output to the log file as Unicode text (appends the output to the existing log file).

  • e.g: robocopy "c:\a" "c:\b" /unilog+:"c:\copy_log.log"

For more details https://technet.microsoft.com/en-us/library/cc733145(v=ws.11).aspx

  • I'll also recommend to add `/tee` switch as that also products command line output and lets user to see the progress of the copying of files in command line also. – vibs2006 Jan 23 '18 at 15:34
1

It happens when need admin privileges/ or pop to create file into that directory

So try to have a log/temp directory and try to add log file into that log directory

$ mkdir C:\log

e.g:

$ robocopy "c:\a" "c:\b" /log:"c:\log\copy_log.log"
slm
  • 7,355
  • 16
  • 54
  • 72
0

If the path to the log file contains spaces or some other scripting delimiters, please include it in quotes such as your EDIT #1 and @slm suggests. But also, please note the use of escape characters as described in this documentation on Batch scripting.

Alain
  • 11
  • 2