34 lines
593 B
Batchfile
34 lines
593 B
Batchfile
@echo off
|
|
setlocal disableDelayedExpansion
|
|
|
|
:Variables
|
|
set InputFile=%1
|
|
set OutputFile=%InputFile%#
|
|
set "_strFind=%2"
|
|
set "_strInsert=%3"
|
|
set "_withoutdelete=%4"
|
|
|
|
:Replace
|
|
>"%OutputFile%" (
|
|
for /F "delims=" %%L in ('findstr /n "^" "%InputFile%"') do (
|
|
set "line=%%L"
|
|
setlocal EnableDelayedExpansion
|
|
|
|
set "line=!line:*:=!"
|
|
if "!line!" neq "" (
|
|
set "_line=!line:%_strFind%=%_strInsert%!"
|
|
) else (
|
|
set _line=!line!
|
|
)
|
|
|
|
echo.!_line!
|
|
endlocal
|
|
)
|
|
)
|
|
|
|
if "%_withoutdelete%"=="" (
|
|
del %InputFile%
|
|
copy %OutputFile% %InputFile%>nul
|
|
del %OutputFile%
|
|
)
|