I'm trying to create a batch file that replaces a line in a text file.
The line is: Window Resolution:
Depending on some settings in my program, this line can look like this:
Window Resolution: 1
Window Resolution: 2
Window Resolution: 3
I need to replace Window Resolution: (number) with Window Resolution: 1 using a batch.
My first guess would be to create something like this:
@echo off
setlocal enableDelayedExpansion
:Variables
set InputFile=configfile.txt
set OutputFile=tempconfigfile.txt
set "_strFind=Window Resolution:"
set "_strInsert=Window Resolution: 1"
:Replace
>"%OutputFile%" (
for /f "usebackq delims=" %%A in ("%InputFile%") do (
if "%%A" equ "%_strFind%" (echo %_strInsert%) else (echo %%A)
)
)
DEL %InputFile%
MOVE %OutputFile% %InputFile%
ENDLOCAL
But I can't get this working... Any advice would be awesome. Thank you.