Batch Script - toInt

A variable which has been set as string using the set variable can be converted to an integer using the /A switch which is using the set variable. The following example shows how this can be accomplished.


@echo off
set var = 13145
set /A var=%var% + 5
echo %var%


The above command produces the following output.


Apart from this, strings have the following implementations which are available. Batch scripts have the following commands which are used to carry out string manipulation in strings.


This can include negative numbers −

%variable:~num_chars_to_skip, -num_chars_to_keep%

Let us discuss the possible string operations that can be performed by using the above commands.