There are two problems in the code.
The first way findstr
works. For each line at its input, it checks whether the line contains (or not) the specified literal or regular expression. The input lines to be tested can be read from a file or from a standard input stream, but not from arguments on the command line. The easiest way to pass a string to findstr
echo %ras% | findstr /c:"already" >nul
The second problem is how the if
command is written. The initial bracket must be on the same line as the condition, the else
clause must be on the same line as the first closing bracket, and the opening bracket in the else
clause must be on the same line as the else
(see here )
if condition ( code ) else ( code )
But to check for the presence of a string in a variable, itβs easier to do
if "%ras%"=="%ras:already=%" ( echo already not found ) else ( echo already found )
This will check if the value in the variable is equal to the same value with the replacement of the already
string with nothing.
Variable information Change / Replace appearance here .
MC ND source share