I have the following code:
set name=James
echo %name:~0,4%
And it displays the first 4 letters of the variable: Jame
.
But I'd like to insert a variable for the number of letters displayed which I can change with set
. Something like this:
set num=3
set name=James
echo %name:~0,%num%%
The result should be showing the first num
characters of string value of variable name
.
Is there any method to get desired result?