Batch Script - Remove Both Ends



This is used to remove the first and the last character of a string

Example

@echo off 
set str = Batch scripts is easy. It is really easy 
echo %str% 

set str = %str:~1,-1% 
echo %str%

The key thing to note about the above program is, the ~1,-1 is used to remove the first and last character of a string.

Output

The above command produces the following output.

Batch scripts is easy. It is really easy 
atch scripts is easy. It is really eas
batch_script_strings.htm
Advertisements