I want to find every line in a text file that contains the word "foo". I set up my if statement like this...
for /f "delims=" %%i in ('type "%textfile%" ^| find /v /n "" ^& break ^> "%textfile%" ') do (
set "line=%%i"
setlocal enabledelayedexpansion
set "wordtofind=foo"
if not "!line!"=="!line:!wordtofind!!" (
set "erase=!line:*=!"
set "newCode=bar"
>>"!textfile!" echo !newCode!
For some reason, the if statement executes when the string "value" is found. Can someone please explain why that is?