Answer by Jamesfo for Getting substring of a token in for loop?
I recently had a similar question, and I wanted to compile here the 3 working solutions:Use EnableDelayedExpansion in your batch file, as in the accepted answer@echo offsetlocal...
View ArticleAnswer by Aacini for Getting substring of a token in for loop?
On the other hand, if you want to know "How to get the last part (name and extension) of a token in for loop", the answer is: use the ~Name and ~eXtension modifiers in %%g replaceable parameter:for /d...
View ArticleAnswer by ChrisWue for Getting substring of a token in for loop?
A simple dir /B %windir%\Assembly\gac_msil\*policy*A.D*should do the trick. If you want to loop over it:for /f %%g in ('dir /B %windir%\Assembly\gac_msil\*policy*A.D*') do ( echo %%g)
View ArticleAnswer by Aacini for Getting substring of a token in for loop?
Of course that set x=%%g and a substring extraction of x should work, but be aware that if the substring is taken inside a FOR loop, it must be done with ! instead of % (Delayed Expansion):setlocal...
View ArticleGetting substring of a token in for loop?
I have this for loop to get a list of directory names:for /d %%g in (%windir%\Assembly\gac_msil\*policy*A.D*) do (echo...
View Article