0

I have the below code that executes and stores the output to a text file, and then display the output to console.

robocopy %TOBEZIPPED% %TEMPDIR% *.* /E > Log.txt & type Log.txt

but since I'm using the robocopy command that shows progress while it is copying, I would like it to show as it was intended and then store the output (maybe history of the command) to a text file..

How can I do it? I've tried doskey /history from a google search but can't still solve my issue.

Hope someone can help me.. Thanks in advance..

EDIT: I have searched related questions but have not found the same with what I wanted.. please note that the result of output should be displayed first normally (not echoed or typed, see robocopy command) before redirecting it to the output file.. so it's like command will display first as usual, like a command history - after execution, will then be redirected to an output file..

  • possible duplicate of [Displaying Windows command prompt output and redirecting it to a file](http://stackoverflow.com/questions/796476/displaying-windows-command-prompt-output-and-redirecting-it-to-a-file) – DavidPostill Nov 18 '14 at 06:15
  • no its not the same.. i already went from that post before posting my question.. what I need is to see the command running (for robocopy, you will see progress of copy every file, every percent) before having it redirected to a log file.. – E-r Gabriel Doronila Nov 18 '14 at 09:03

1 Answers1

0

For Shell only:

Use tee:

tee is a command in command-line interpreters (shells) using standard streams which reads standard input and writes it to both standard output and one or more files, effectively duplicating its input.

e.g.

 robocopy %TOBEZIPPED% %TEMPDIR% *.* /E | tee -a Log.txt 

If you want to do it in windows you need to use PowerShell http://en.wikipedia.org/wiki/Windows_PowerShell . This will provide you tee command to be executable on windows.

Amit Kumar
  • 313
  • 1
  • 4
  • 14