@echo off
:: Replace the ### character in the first line.
:: In the second line character in use, replace the @@@ character in use.
:: ……
:: If the Mth row contains the content S(M<N) to be replaced in the Nth row, S will be replaced with the matching content containing the Mth row
:: For example: Assuming that the first line contains @@@ to be replaced in the second line, the @@@ that contains the first line will be replaced with @@@@.
::Usage format: To replace S with the content of line M, add a sentence to the position of line M:_replace S
::If there is nothing to replace on the Nth line, add set num=N at the Nth line
setlocal enabledelayedexpansion
set num=0
call :_replace ###
call :_replace @@@
set num=3
call :_replace $$$
exit
:_replace
set /a num+=1
set char=%1
for /f "tokens=1,2* delims=:" %%i in ('findstr /n . ') do if %%i equ %num% set str=%%j
for /f "delims=" %%i in () do (
set _str=%%i
set "_str=!_str:%char%=%str%!"
echo !_str!>>
)
move