Software >> OS >> Windows >> Command Line >> How to manipulate variables in a batch file

(1) Adding a number or incrementing a variable set var1=1 set var2=1 set /a sum1=%var1%+%var2% echo %sum1% (2) extract a length of substring from an offset and set var=one.twothree set /a var2 = %var:~4.3% echo %var2% will yield "two" (3 characters from offset 4 i.e. 5th character) set var=one.twothree set /a var2 = %var:~4% echo %var2% will yield "twothree" (substring after offset 4 i.e. 5th character onwards)