Hello, Beach Boy. Here some script.
"sourceFolder" - is a folder with files that need replaces. (reading without subfolders)
"mask" - for some additional filtering.
Destination is the same folder, but the name of file was created with prefix _2
Also, I prefer to use "find", not "findstr" - less bugs.
Code: Select all
@echo off
setlocal enableDelayedExpansion EnableExtensions
set "replace=system"
set "replaced=offline"
set sourceFolder=c:\temp
set mask=*.reg
for /f "delims=" %%F in ('dir /b /a-d "%sourceFolder%\%mask%"') do (
(
for /F "tokens=1* delims=]" %%a in ('find /N ^< "%sourceFolder%\%%F"') do (
set "line=%%b"
if defined line set "line=!line:%replace%=%replaced%!"
echo.!line!
)
) > "%sourceFolder%\%%~nF_2%%~xF"
)
Best regards, Alex.