|How about this:|
FOR /F %%A IN (some.ini) DO (
ECHO %%A |FINDSTR /V "^vCTI_XDIM ^vCTI_YDIM" >>tmp
IF /I !ERRORLEVEL! EQU 1 (
ECHO %%A |FINDSTR "vCTI_XDIM" > NUL
IF /I !ERRORLEVEL! EQU 0 (
) ELSE (
MOVE "tmp" "some.ini"
A rundown of what's happening:
First, the batch environment is setup to run quietly, and to allow variables within a loop to be usable. An empty temp file is created, which will contain a new ini file reflecting the desired values. A loop is started, reading line by line the contents of the current ini file. Each line is then assessed using the FINDSTR command. Any line that doesn't begin with vCTI_XDIM or vCTI_YDIM gets written to the temp file. If a line does begin with either vCTI_XDIM or vCTI_YDIM, the line is explicitly tested (again, with the FINDSTR command) to see if vCTI_XDIM is found. If it is, the desired value for it is written to the temp file. If the line doesn't contain vCTI_XDIM, it must therefore contain vCTI_YDIM, and it's desired value is written to the temp file. Once all the lines have been assessed, the MOVE command overwrites the old ini file with the temp file that contains all of the desired values. The batch file is done, and EXITs.
You should be able to copy and paste all of the fixed-font text into Notepad (replacing all occurrences of "some.ini" with the name of your own .ini file), and save it as "UpdateINI.bat" in the same folder as your .ini file you want updated.
When your only tool is a hammer, every problem looks like a nail.