| 1. |
Solve : substring question? |
|
Answer» Within a Windows XP batch file I NEED to find a substring within a variable string and then do something if it is equal or not equal. Find and FindStr seem to only work with files so I was wondering just how to do this with a variable in an if statement. Hi, reno It is a small relative of your %%G Quote from: Geek-9pm on April 18, 2009, 11:34:22 PM Hi, renoQuote from: Z.K. on April 18, 2009, 07:00:19 PM if %%G contains "command" (there is indention in the above code, i assume he is inside a for loop, %%g refers to token variable. besides for loop, i can't think anywhere else in coding a %%g can be used. Code: [Select]for /f "tokens=1*" %%f in (sometextfile.txt) do ( echo %%g|find "command" >nul 2>&1 && echo a message ) example text file: this is a command sample output: c:>\test.bat a message for complete explanation, type for/?Thanks, It said: To use the FOR command in a batch program, specify %%variable instead of %variable. Variable NAMES are case sensitive, so %i is different from %I. It also said the variable is onl a single LETTER. |
|