Batch scripting is a text file containing a series of commands intended to be executed by the command interpreter. Much like a unix / linux shell script, the purpose of a batch script is to sequentially process a series of commands.

Tags | |

Batch script math (Adding and subtracting in a batch script)

Baed on search traffic, I notice that alot of people are looking for how to add and subtract using a batch script. This is actually really easy.

In the example below I am going to set a base number for the example and then add or increment up the value. You can copy the code below and save it as counting.bat


@echo off
set count=1
set /a count=%count%+1
echo %count%
set /a count=%count%+1
echo %count%
set /a count=%count%+10
echo %count%
set /a count=%count%-1
echo %count%
pause


The result is pretty clear. If you still need more information feel free to leave a message below and I can give a more detailed example.



Comments

Feel free to leave a comment or question

Name: (Optional but appreciated):

Comment:

Use [code] [/code] for code block style



Security Code: