I’m trying to add two numbers together in a windows batch file. The numbers are coming from the output of a command and I cannot change the code to output it in a different format.
The problem is that the numbers use commas in the numbers as the thousands separator. i.e. 154022 is output as 154,022. Now when I try to add this number to another number it only adds the first part (i.e. that 154).
set A=1,000
set B=154,022
set /a TOTAL=A + B
echo %TOTAL%
produces: 155, not 155022 that I would like, or even 155,022 would do.
Is there a way to convert easily from numbers with commas to numbers without commas in a batch script?
You can do string manipulation like this
This one and other nice tips: http://www.dostips.com/DtTipsStringManipulation.php