Can robocopy show the console and create a log file?

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?

BitBug

Posted 2015-04-11T00:10:36.047

Reputation: 215

Answers

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.

Karan

Posted 2015-04-11T00:10:36.047

Reputation: 51 857

Worked like a charm! is the /np flag so the progress indicator doesn't gum up the log? Thanks for the assist! – BitBug – 2015-04-11T20:24:20.840

1Yes, otherwise I found lines with just progress percentages in them and nothing else. You can omit it of course as you see fit. – Karan – 2015-04-12T04:13:31.517

Thank you. If you can up vote, that will help me get to 15 on this board. – BitBug – 2015-04-13T16:03:52.150

@BitBug: Done. :) – Karan – 2015-04-13T19:13:23.350