The idea is I want to check if a substring is inside of a string with Batch script.
For example I want to check if pass is inside of %rev%. If no for loop is related, I can do:
if /I "%rev:pass=%" neq "%rev%" (
echo String has pass
) else (
echo it doesnt has pass
)
But I don't know how to use this "%rev:pass=%" in side of a for loop when "%rev%" is replaced by %%g
My code is here:
FOR /F "tokens=*" %%g IN (test.txt) do (
if /I "%%g:pass=" neq "%%g" (
echo String has pass
) else (
echo it doesnt has pass
)
)
I need to check each string inside of this test.txt if it has substring pass. Any help is appreciated.
I try to change the form of %%g but still cannot make it happen. The main idea is to check each string in the file, if the string has pass as a sub-string
Findcan show you each line containing the case insensitive stringpass, i.e.@%SystemRoot%\System32\find.exe /I "pass" 0<”test.txt". Conversely@%SystemRoot%\System32\find.exe /I /V "pass" 0<”test.txt"will show you each line which doesn't contain the case insensitive stringpass. You could also do it withFindStr:@%SystemRoot%\System32\findstr.exe /I "pass" ”test.txt", and@%SystemRoot%\System32\findstr.exe /I /V "pass" ”test.txt"respectively.