thanks it worked well, you actually make the SR.EXE (string replacer.exe) in your script. and i tried to make a subroutine out of it CALL :SR FILE "%%~a", it also worked but AA='s ECHO %FIND% has different strings than BB='s ECHO %FIND%, i spent several hours to find the reason, but none found by the trial and error method but i just accepted that it worked at the end.
SR.EXE (string replacer.exe) works even when input data contains \ and % and ^ except for ""
>Another important problem is the replacement of a string that contains equals signs
it worked with the input data that have =s
>Finally, in the example it is not clear if a find string can contain several (variable number of) blank spaces.
so i tried below and all worked
Code: Select all
"ZoomP ause Percent=100" "ZoomPausePercent = 0"
"ZoomP ause Percent=100" "ZoomPaus ePercent=0"
"Zoom P a use Perc ent = 100" "ZoomP ausePercent=0"
dosbox uses cycles (how many spaces) = (how many spaces) 1, "how many spaces" are all different from file to file so i havent used it on dosbox's conf yet
AA=
Code: Select all
@echo off
setlocal EnableDelayedExpansion
set "file=JPEGView.ini"
set "find="
for %%a in (
"Units=auto" "Units=metric"
"SlideShowTransitionEffect=Blend" "SlideShowTransitionEffect=None"
"SlideShowEffectTime=250" "SlideShowEffectTime=1"
"ShowNavPanel=true" "ShowNavPanel=false"
"ShowBottomPanel=true" "ShowBottomPanel=false"
"ShowZoomNavigator=true" "ShowZoomNavigator=false"
"AllowFileDeletion=true" "AllowFileDeletion=false"
"SkipFileOpenDialogOnStartup=false" "SkipFileOpenDialogOnStartup=true"
"ZoomPausePercent=100" "ZoomPausePercent=0"
"AutoZoomMode=FitNoZoom" "AutoZoomMode=Fill"
"ShowFullScreen=auto" "ShowFullScreen=false"
"DefaultWindowRect=image" "DefaultWindowRect=19 1 504 1050"
) do (
CALL :SR FILE "%%~a"
)
GOTO :END
:SR
if not defined find (
set "find=%2"
) else (
set "lastLine=0"
SET "FILE=%~1"
[b]ECHO %FIND%[/b]
PAUSE
< "%file%" (
for /F "delims=:" %%i in ('findstr /N /C:"!find!" "%file%"') do (
set /A "skip=%%i-lastLine-1, lastLine=%%i"
for /L %%s in (1,1,!skip!) do (
set "line="
set /P "line="
echo(!line!
)
set /P "line="
echo %%~a
)
findstr "^"
) > temp.tmp
move /Y temp.tmp "%file%" > NUL
set "find="
set "%1=%FILE%"
)
EXIT /B
:END
*****************************************************************
BB=
Code: Select all
@echo off
setlocal EnableDelayedExpansion
set "file=JPEGView.ini"
set "find="
for %%a in (
"Units=auto" "Units=metric"
"SlideShowTransitionEffect=Blend" "SlideShowTransitionEffect=None"
"SlideShowEffectTime=250" "SlideShowEffectTime=1"
"ShowNavPanel=true" "ShowNavPanel=false"
"ShowBottomPanel=true" "ShowBottomPanel=false"
"ShowZoomNavigator=true" "ShowZoomNavigator=false"
"AllowFileDeletion=true" "AllowFileDeletion=false"
"SkipFileOpenDialogOnStartup=false" "SkipFileOpenDialogOnStartup=true"
"ZoomPausePercent=100" "ZoomPausePercent=0"
"AutoZoomMode=FitNoZoom" "AutoZoomMode=Fill"
"ShowFullScreen=auto" "ShowFullScreen=false"
"DefaultWindowRect=image" "DefaultWindowRect=19 1 504 1050"
) do (
if not defined find (
set "find=%%~a"
) else (
[b]ECHO %FIND%[/b]
PAUSE
set "lastLine=0"
< "%file%" (
for /F "delims=:" %%i in ('findstr /N /C:"!find!" "%file%"') do (
set /A "skip=%%i-lastLine-1, lastLine=%%i"
for /L %%s in (1,1,!skip!) do (
set "line="
set /P "line="
echo(!line!
)
set /P "line="
echo %%~a
)
findstr "^"
) > temp.tmp
move /Y temp.tmp "%file%" > NUL
set "find="
)
)