I'm looking for some help. I want to create a batch file that can find a particular line inside a text file and then insert a line below it and enter some text from the batch file.
Example I want to insert a line after "2"
Text file 1 2 3
The batch would find "2" create a new line and enter the word "Two". The number one would be within the text file, this could be any word.
The text file would be store on the C:\
@echo off
setlocal enabledelayedexpansion
ren in.txt in.tmp
set p=
for /f %%a in (in.tmp) do (
if "%%a"=="1" if "!p!"=="3" Echo Two >> in.txt
Echo %%a >>in.txt
set p=%%a
)
del in.tmp