Windows Batch: Split String to individual characters to variables
问题 in Windows Batch, if I had a variable (length can change) that was, for example: "hello world!" is it possible to "split" the variable so each character is its own variable so the output could look like: t1=h t2=e t3=l etc. Any help would be appreciated. 回答1: Use this code: setlocal EnableDelayedExpansion set str="hello world^!" set tempstr=%str% set count=0 :loop if defined tempstr ( set tempstr=%tempstr:~1% set /a count+=1 set /a pos=%count%-1 set t!count!=!str:~%pos%,1! goto loop ) ::