string replacer for 1 file but it needs looping to replace many OldStrings with NewStrings
Posted: 17 Mar 2025 19:55
a difficult part of updating a software is NOT replacing an EXE or DLLs
it is about how to re-modify INI and CONF again whose filesizes vary from 50k ~ 250K frequently, finding target strings causes a lot of headache in large files. i hope to put an end to this, my initial batch drawing board looks like this below.
%1 means an input filename
these are old strings
"cycles = auto"
"time = 1"
"ShowNavPanel=true"
"ShowBottomPanel=true"
"ShowZoomNavigator=true"
"ZoomPausePercent=100"
these are new strings
"cycles = max"
"time = 3"
"ShowNavPanel=false"
"ShowBottomPanel=false"
"ShowZoomNavigator=false"
it is about how to re-modify INI and CONF again whose filesizes vary from 50k ~ 250K frequently, finding target strings causes a lot of headache in large files. i hope to put an end to this, my initial batch drawing board looks like this below.
Code: Select all
@ECHO OFF
Setlocal EnableExtensions DisableDelayedExpansion
FOR %%V IN (
"cycles = auto" "cycles = max"
"time = 1" "time = 3"
"ShowNavPanel=true" "ShowNavPanel=false"
"ShowBottomPanel=true" "ShowBottomPanel=false"
"ShowZoomNavigator=true" "ShowZoomNavigator=false"
"ZoomPausePercent=100" "ZoomPausePercent=0"
) DO (
"STRING REPLACER.EXE" "%oldstring%" "%newstring%" %1
)
:END
pause
these are old strings
"cycles = auto"
"time = 1"
"ShowNavPanel=true"
"ShowBottomPanel=true"
"ShowZoomNavigator=true"
"ZoomPausePercent=100"
these are new strings
"cycles = max"
"time = 3"
"ShowNavPanel=false"
"ShowBottomPanel=false"
"ShowZoomNavigator=false"