4

I'm working with robocopy for the first time and have got most of it figured out and working well except logging.

I have experimented a bunch and if I run my job like this:

robocopy /xc /xn /xo "source" "destination" *.* /COPY:DAT /E  

I see my job running line by line in the powershell console.

If I run it like this:

robocopy /xc /xn /xo "source" "destination" *.* /COPY:DAT /E /L LOG:mylogfile.log

I get a "dry run" file showing me what will happen when I run it "for real"

And when I run it like this:

robocopy /xc /xn /xo "source" "destination" *.* /COPY:DAT /E /LOG:mylogfile.log

The job executes, but I do not see anything on the console except:

Log File : mylogfile.log

with a blinking cursor until the job is done. Once the job completes, then I can see the results in my log.

My understanding is robocopy does not create a log by default. My question is, is there a way to have both the console showing the line by line progress like my 1st set of commands above AND log the job to a file like my 3rd set of commands all in one run?

4

Looks like you need some tee. (Not the drinkable variety although you might enjoy a cup of that too while robocopy does its thing. :)

powershell -command "robocopy 'drive:\source dir' 'drive:\target dir' /np | tee 'drive:\log file.log'"

(Or just type powershell and then at the PS prompt type your robocopy command piped via tee to the log file.)

Edit: Ok, now I just feel dumb, because robocopy has an in-built /tee parameter that I can't believe I never noticed earlier.

4
  • Worked like a charm! is the /np flag so the progress indicator doesn't gum up the log? Thanks for the assist! – BitBug Apr 11 '15 at 20:24
  • 1
    Yes, otherwise I found lines with just progress percentages in them and nothing else. You can omit it of course as you see fit. – Karan Apr 12 '15 at 4:13
  • Thank you. If you can up vote, that will help me get to 15 on this board. – BitBug Apr 13 '15 at 16:03
  • @BitBug: Done. :) – Karan Apr 13 '15 at 19:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.