here\'s a text file txtfile.txt
line1
line2
add after this line
line4
etc
etc
i want to create a batch file which can add a li
@ECHO OFF
SETLOCAL
SET /p info="enter info : "
:: read addafter line
(
FOR /f "delims=" %%i IN (poison1.txt) DO (
SET addafter=%%i
FOR /f "delims=" %%n IN (' findstr /n "^" txtfile.txt') DO (
SET line=%%n
SETLOCAL ENABLEDELAYEDEXPANSION
SET line=!line:*:=!
ECHO(!line!
IF "!line!"=="!addafter!" ECHO(%info%
ENDLOCAL
)
)
)>newfile.txt
FC newfile.txt txtfile.txt
GOTO :eof
Where poison1.txt
contains the one line
"A line !of! ] many < & >var*ied %poison ^ char;ac(ters) | like "," a\nd+so=on"
and txtfile.txt contains this line.
poison1.txt
file to addafter
FINDSTR
) done!