windows xp - How can I add totals from a file in a dos batch -


i want add totals lines in text file.

my file.txt looks this:

totals: 7 passed, 0 failed, 0 skipped totals: 10 passed, 0 failed, 0 skipped totals: 6 passed, 0 failed, 0 skipped totals: 9 passed, 0 failed, 0 skipped totals: 4 passed, 0 failed, 1 skipped totals: 31 passed, 0 failed, 0 skipped totals: 10 passed, 0 failed, 0 skipped totals: 4 passed, 0 failed, 0 skipped totals: 8 passed, 0 failed, 0 skipped 

so when run sumtotals.bat file.txt want this:

passed : xx failed : 0 skipped: x 

you can this:

@echo off  set passed=0 set failed=0 set skipped=0  /f "tokens=2,4,6 delims= " %%a in (%1) call :add %%a %%b %%c  echo passed=%passed% echo failed=%failed% echo skipped=%skipped%   goto :eof   :add rem echo %1 %2 %3 set /a passed=%passed%+%1 set /a failed=%failed%+%2 set /a skipped=%skipped%+%3   :eof 

result:

c:\temp>sumtotals.bat file.txt passed=89 failed=0 skipped=1 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -