Help capturing timeit output

Hello -

I have the following batch command

timeit copy C:\pic.jpg z:\ /y

using basic > output.log, etc.. I am not able to capture the data output of timeit (provides timing info for my copy command) - any ideas?

Who is Participating?
Computer101Connect With a Mentor Commented:
PAQed with points refunded (500)

EE Admin
when you type :timeit copy C:\pic.jpg z:\ /y on the command line, what did you see? what happens?
TimeIt.exe writes, for whatever reason (probably so as not to interfere with the output of the command it's running) to stderr.
You can capture the output in a log file by redirecting stderr to the log file:

timeit whatever.exe 2>ouput.log
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

newtontech4Author Commented:
hi ghostdog74
Here is the output of the command -  notice since timeit is a windows resource utility I run it and my batch from it's home directory...

C:\Program Files\Windows Resource Kits\Tools>timeit copy.bat

C:\Program Files\Windows Resource Kits\Tools>copy C:\pic.jpg z:\ /y
        1 file(s) copied.

Version Number:   Windows NT 5.1 (Build 2600)
Exit Time:        9:22 am, Friday, October 12 2007
Elapsed Time:     0:00:00.390
Process Time:     0:00:00.031
System Calls:     4294
Context Switches: 2454
Page Faults:      788
Bytes Read:       1752298
Bytes Written:    775200
Bytes Other:      108340
newtontech4Author Commented:
Hi oBdA -

Thanks for your feedback.  I am hoping you can elaborate a little more.

I noticed that the timeit sends output to it's own dat file - which for the life of me I have no idea how to read.

TIMEIT's .DAT file is binary encoded but it's really not necessary for us to read it in order to do as you require, try this command in your batch file -

for /f "tokens=3-5 delims=. " %%t in ('timeit 2^>^&1 copy C:\pic.jpg z:\ /y ^| find /i "Elapsed"') do set timeTAKEN=%%t.%%u

oBdA was correct in that TIMEIT writes to stderr.  The notion of text handling at the command prompt is divided into 3 possible data streams known as stdout, stderr and stdin (standard out, standard error and standard in).  Non-error related messages should, according to convention, be written by the application to stdout while errors should be written to stderr.  Input is accepted from stdin.  stdout can be redirected using the following syntax -

dir 1> MYoutput.txt (or abbreviated to dir >MYoutput.txt)

... while errors can be redirected using -

cd THISdoesNOTexist 2> hereISmyERROR.log

The '1' and '2' prefixing the '>' symbol allow us to designate stdout or stderr redirection respectively.  To redirect stdin, i.e. accept input from somewhere other than the keyboard, use a '<' symbol typically followed by a filename containing the text we'd like entered as automated input.

The special syntax '2>&1' tells the command shell to send stderr through the same output stream as stdout allowing a script to capture both the stdout and stderr output steams in one pipeline.

The '^' symbol you see me using in the example I provided prevents the command prompt from applying the redirection or piping components too early in the execution of the statement.
newtontech4Author Commented:
Thanks to all for your contributions on this.

I have decided to run with robocopy - the following works like a charm.
robocopy "C:\1" "C:\2" /MIR /COPYALL /V /NC /NDL /NP /NFL /LOG:"C:\MYLOGFILE.log" /R:10 /W:30 /ETA

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.