Right String

Extract characters from the end of a string.

Description: Similar to the Right function in VB a batch script can return a specified number of characters from the right side of a string by specifying a substring for an expansion given a negative position using :~ while expanding a variable content. The example shows how to return the last 4 characters of a string.
Script:
1.
2.
3.
4.
set str=politic
echo.%str%
set str=%str:~-4%
echo.%str%
Script Output:
 DOS Script Output
politic
itic