Computing.Net > Forums > Programming > batch Programming

batch Programming

Reply to Message Icon

Original Message
Name: dinger
Date: June 28, 2007 at 05:41:28 Pacific
Subject: batch Programming
OS: Windows XP Pro
CPU/Ram: NA
Model/Manufacturer: Dell
Comment:

I currently use a batch script which uses xcopy to copy multiple files from one folder to another. it also logs the start time and end time of the copy.
I have to modify this script to give me more information about the copy - I have to know elapsed time for the copy and the size of the data copied.
Can this be done using regular batch programming, or will I have to get into some sort of scripting.
If I do end up using vbscripting or something similar, will I see a large performance difference?


Report Offensive Message For Removal


Response Number 1
Name: IVO
Date: June 28, 2007 at 06:20:15 Pacific
Reply: (edit)

The information you want to catch can be processed by a batch script, pointed out

- NT batch language can perform basic arithmetics, so you can compute the elapsed time from the start and stop one, but that requires your own coding.

- to compute the size of data xcopied can be achieved using variable modifier ~z and again the proper code to process the log that xcopy can produce.

What above stated is not a mission impossible, but not so easy to achieve.


Report Offensive Follow Up For Removal

Response Number 2
Name: dinger
Date: June 28, 2007 at 08:42:10 Pacific
Reply: (edit)

Thanks. I am having trouble getting the size of the file. I have the log and variables working, but just can't find out how to get the size.


Report Offensive Follow Up For Removal

Response Number 3
Name: IVO
Date: June 28, 2007 at 13:57:36 Pacific
Reply: (edit)

To take in account the size of data transferred start your batch as below

@Echo Off
SetLocal EnableDelayedExpansion

Then insert where it's right for you the statements

Set Count=0
For /f "tokens=* delims=" %%i in (xcopy.log) Do (
If exist %%i Set /A Count+=%%~zi)
Echo Data transferred is %Count% bytes

where xcopy.log is the log generated by an extra (never mind, it's fast) run of your xcopy command with the /L switch, e.g.

xcopy source destination /L > xcopy.log

I hope this helps for the size issue. To compute the elapsed time is far more complex as it requires tedious arithmetics.

Post again if you need more support; report *exactly* a sample of your start/stop time, so I can take a look at its format and maybe give you some tips (not granted).


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: batch Programming

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




Have you ever used OpenOffice?

Yes, as my main suite.
Yes, occationally.
Yes, but only once.
No, never.


View Results

Poll Finishes In 5 Days.
Discuss in The Lounge