Can robocopy show the console and create a log file?

14,639

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.

Share:
14,639

Related videos on Youtube

BitBug
Author by

BitBug

Bit Bug is a certifiable techno-addict who loves all things technology. Having a passion for learning technology, Bit Bug has self taught himself since writing his first "Hello World" in Basic at the age of 11 on an Apple ][ in 1981. After getting sidetracked by a 17 year corporate career culminating as COO of a multi-million dollar corporation, Bit Bug left the corporate world in favor starting a business doing what he loves; technology in all its forms. You can find him working on his business by day and teaching himself new technology by night in all its forms.

Updated on September 18, 2022

Comments

  • BitBug
    BitBug over 1 year

    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
    BitBug about 9 years
    Worked like a charm! is the /np flag so the progress indicator doesn't gum up the log? Thanks for the assist!
  • Karan
    Karan about 9 years
    Yes, otherwise I found lines with just progress percentages in them and nothing else. You can omit it of course as you see fit.
  • BitBug
    BitBug about 9 years
    Thank you. If you can up vote, that will help me get to 15 on this board.
  • Karan
    Karan about 9 years
    @BitBug: Done. :)