54 lines
1.0 KiB
Batchfile
54 lines
1.0 KiB
Batchfile
setlocal disableDelayedExpansion
|
|
|
|
:Variables
|
|
set InputFile=%2
|
|
set OutputFile=%InputFile%#
|
|
set entity=%1
|
|
set "_strFind=Check_Dynamic_EntityControllers"
|
|
set _strInsert1=[InlineData("%entity%")]
|
|
set "_strInsert1= %_strInsert1%"
|
|
|
|
rem if already inserted, do nothing
|
|
:Check
|
|
for /F "delims=" %%L in ('findstr /n "^" "%InputFile%"') do (
|
|
set "line=%%L"
|
|
setlocal EnableDelayedExpansion
|
|
|
|
set "line=!line:*:=!"
|
|
if "!line!" neq "" (
|
|
set "_line=!line:%_strInsert1%=!"
|
|
) else (
|
|
set _line=!line!
|
|
)
|
|
if "!_line!" neq "!line!" goto finish
|
|
endlocal
|
|
)
|
|
@echo off
|
|
|
|
: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%=!"
|
|
) else (
|
|
set _line=!line!
|
|
)
|
|
|
|
|
|
if "!_line!" neq "!line!" (
|
|
echo !_strInsert1!
|
|
)
|
|
echo.!line!
|
|
endlocal
|
|
)
|
|
)
|
|
|
|
del %InputFile%>nul
|
|
copy %OutputFile% %InputFile%>nul
|
|
del %OutputFile%>nul
|
|
|
|
:finish |