Jump to content

batch file to time how long it takes to copy files?


graysky

Recommended Posts

I'd like to test out my new network gear without using a stopwatch. Is there an easy way to literally time how long it takes to copy files from one location to another and when finished, report the total time via a batch file?

Thanks!

Link to comment
Share on other sites


i made this batch file..

time /T
xcopy "C:\test.txt" "d:" /y
time /T

and dragged it into a command window and typed

> c:\output.txt

after it. in the output.txt text file it told me what time it started and what time it finished. so it does work :) but it doesnt tell you in seconds, only minutes :(

Edited by eyeball
Link to comment
Share on other sites

OK.. I get it... yeah I need seconds. Too bad windows doesn't work like LINUX does... if I do the following in LINUX:

$ time cp file /copy/to

It copies the file and reports the time it took to copy the file in three formats where "real" is the actual time it took to copy the file:

real	0m0.695s
user 0m0.004s
sys 0m0.260s

Edited by graysky
Link to comment
Share on other sites

Robocopy can do this.

http://www.ss64.com/nt/robocopy.html

Output:

------------------------------------------------------------------------------
ROBOCOPY :: Robust File Copy for Windows
------------------------------------------------------------------------------

Started : Thu Dec 14 17:25:16 2006

Source : C:\Users\User\AppData\Local\Temp\
Dest : F:\

Files : bigfile.iso

Options : /COPY:DAT /R:1000000 /W:30

------------------------------------------------------------------------------
1 C:\Users\User\AppData\Local\Temp\
100% New File 1.4 g bigfile.iso
------------------------------------------------------------------------------

Total Copied Skipped Mismatch FAILED Extras
Dirs : 1 0 1 0 0 0
Files : 1 1 0 0 0 0
Bytes : 1.456 g 1.456 g 0 0 0 0
Times : 0:01:45 0:01:45 0:00:00 0:00:00

Speed : 14782954 Bytes/sec.
Speed : 845.887 MegaBytes/min.

Link to comment
Share on other sites

There's a section in HFSLIP that will do this.

I have only the relevant sections posted below. You may copy and modify it to suit your needs. All credit goes to Tomcat76, who wrote the code for it.

Paste before copy section

:TIMECALC
FOR /F "TOKENS=2,3 DELIMS=:. " %%Q IN ('ECHO %TIME%') DO SET ETIMEM=%%Q&SET ETIMES=%%R
IF NOT "%STIMEM%"=="00" IF %STIMEM% LSS 10 FOR /F "TOKENS=1 DELIMS=0" %%I IN ('ECHO %STIMEM%') DO SET STIMEM=%%I
IF NOT "%STIMES%"=="00" IF %STIMES% LSS 10 FOR /F "TOKENS=1 DELIMS=0" %%I IN ('ECHO %STIMES%') DO SET STIMES=%%I
IF NOT "%ETIMEM%"=="00" IF %ETIMEM% LSS 10 FOR /F "TOKENS=1 DELIMS=0" %%I IN ('ECHO %ETIMEM%') DO SET ETIMEM=%%I
IF NOT "%ETIMES%"=="00" IF %ETIMES% LSS 10 FOR /F "TOKENS=1 DELIMS=0" %%I IN ('ECHO %ETIMES%') DO SET ETIMES=%%I
SET /A TMIN=%ETIMEM%-%STIMEM%
SET /A TSEC=%ETIMES%-%STIMES%
ECHO>TTEST.TXT %TSEC%
FOR /F %%I IN ('FINDSTR/R "\-" TTEST.TXT') DO SET SERROR=1
IF DEFINED SERROR CALL :NSTIMES
ECHO>TTEST.TXT %TMIN%
FOR /F %%I IN ('FINDSTR/R "\-" TTEST.TXT') DO SET MERROR=1
DEL/Q/F TTEST.TXT
IF DEFINED SERROR (SET NSTIMEM=59) ELSE (SET NSTIMEM=60)
IF DEFINED MERROR CALL :NSTIMEM
IF %TSEC% LSS 10 SET TSEC=0%TSEC%
SET RTIMELN=Total run time: %TMIN% min %TSEC% sec
ECHO.
ECHO %HFTOT% hotfixes processed. %RTIMELN%
ECHO.
GOTO EOF

:NSTIMES
SET /A NSTIMES=60-%STIMES%
SET /A TSEC=%NSTIMES%+%ETIMES%
SET /A TMIN=%TMIN%-1
GOTO EOF

:NSTIMEM
SET /A NSTIMEM=%NSTIMEM%-%STIMEM%
SET /A TMIN=%NSTIMEM%+%ETIMEM%
GOTO EOF

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...