I would like to request an assist for this case. I want to get the second word of title so that I could set it as target file.
set title=THE PROGRAM TITLE HERE
set title=one two three four five
for /f "tokens=2" %%i in ("%title%") do set word2=%%i
echo %word2%
This basically grabs the second token (word) from the string. Change the number behind tokens=
into another to get another word. You can also use tokens=2,4
to get the 2nd and 4th word. Additional tokens can be retrieved from %%j
, %%k
etc.
See for /?
for more info.
You could call a local subroutine, passing the title unquoted. In the subroutine, that would give you a list of parameters, e.g., %1
for "THE", %2
for "PROGRAM".
Something like
call :second
echo The second word is %second_word%
and later:
:second
set second_word=%2
goto :eof