I've created a simple batch file that searches in files with extension .opr and .eng for the term @DLOG_ETS
and replace it with @DLOG_ETS=OFF
. This may be redundant for cases where the full string is @DLOG_ETS=OFF
.
I want to add the condition that only if the string @DLOG_ETS=ON
is present, then I want to replace that with @DLOG_ETS=OFF
. Otherwise, I want to leave it as it is, i.e. @DLOG_ETS=OFF
without making any changes on those .opr or .eng files.
for %%F in (*.opr *.eng) do (
type "%%F"| findstr /v @DLOG_ETS= >"%%F.new"
@echo @DLOG_ETS=OFF >> "%%F.new"
move /y "%%F.new" "%%F"
)
For each file, create a new file, removing the line containing the target string. Compare the before and after versions. If there is a difference therefore the string was removed, so append the required line. If no difference, simply delete the new file.