My batch script is written for measuring how much traffic between two PCs a network can handle. So the script determines the size of a file and send it from one PC to another and count how many times this works. But there is a weird problem on the calculation of total number of successfully transfered bytes. The value of environment variable asdf3
printed via echo
after the calculation seems to be inaccurate.
echo hat %count% mal geklappt
echo size: %menge% byte
set /a asdf3=%count%*%menge%
echo es wurden %asdf3% byte verschoben
The lines above produce this output:
hat 58 mal geklappt
size: 30245 byte
es wurden 2722050 byte verschoben
It should be 1754210 (58 * 30245) if my math is okay.
The variables are initialized like this:
set file="test.odt"
FOR /F "usebackq" %%A IN ('%file%') DO set /A menge=%%~zA
set /A count=0
:marker
COPY /Y /V %file% \\%name%\Users\public
if 0==%errorlevel% (
set/Acount=%count%+1
goto :marker
)
Why does evaluation of the simple arithmetic expression in batch file produce 2722050
instead of expected result 1754210
?