Batch Script - Right String



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

Example

@echo off 
set str = This message needs changed. 
echo %str% 

set str = %str:~-8% 
echo %str%

The key thing to note about the above program is, the right hand of the string is extracted by using the ~-‘number of characters to extract’ operator.

Output

The above command produces the following output.

This message needs changed. 
changed.
batch_script_strings.htm
Advertisements