Using a Variable in String Manipulation
Posted: 06 Dec 2011 23:30
Hello,
I have a batch file that loops n amount of times until an IF statement is true. Each time it loops, it sets a variable to a new value (set /a num+=1). I want to use this variable (num) as part of a string manipulation number:This, however, does not seem to work.
I've also tried:This does not seem to work either. Perhaps I am using DelayedExpansion incorrectly, but I don't know because I'm still not all that familiar with how DelayedExpansion works.
Thanks for any help!
I have a batch file that loops n amount of times until an IF statement is true. Each time it loops, it sets a variable to a new value (set /a num+=1). I want to use this variable (num) as part of a string manipulation number:
Code: Select all
IF /I %VAR:~%num%,1%=="A" [do commands]
I've also tried:
Code: Select all
SETLCOAL ENABLEDELAYEDEXPANSION
IF /I !VAR:~%num%,1!=="A" [do commands]
Thanks for any help!