Batch Script - Left String


Advertisements

This is used to extract characters from the beginning of a string.

Example

set str=Helloworld
echo.%str%
set str=%str:~0,5%
echo.%str%

The key thing to note about the above program is, ~0,5 is used to specify the characters which needs to be displayed. In this case, we are saying character 0 to 5 should be displayed.

Output

The above command produces the following output.

Helloworld 
Hello
Advertisements