title: Batch File Find and Insert Line In A Text File
body: <p>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.</p>
  
  <p>Example 
  I want to insert a line after "2"</p>
  
  <p>Text file
  1
  2
  3</p>
  
  <p>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.</p>
  
  <p>The text file would be store on the C:\</p>
  
  <pre><code>@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 &gt;&gt; in.txt
  Echo %%a &gt;&gt;in.txt
  set p=%%a
  )
  del in.tmp
  </code></pre>