title: Batch: insert lines from a .txt file into a .txt file
body: <p>I am completely new to Batch files and have been tinkering around with simple commands.  I have figured out how to move text to another file, find a line etc., but I want to be able to add a few lines of text into an already existing text file.  Here is what I have so far:</p>
  
  <pre><code>@ECHO OFF
  CD C:\Documents and Settings\SLZ1FH\Desktop\New Folder
  FOR /F "tokens=*" %%A IN (Examples.txt) DO (
    ECHO %%A
    IF %%A=="Ex3 3"(
      TYPE Line_to_add.txt &gt;&gt; Examples.txt
    )
  )
  </code></pre>
  
  <p>if Examples.txt contains: </p>
  
  <ul>
  <li>Ex1 1 </li>
  <li>Ex2 2</li>
  <li>Ex3 3 </li>
  <li>Ex4 4 </li>
  <li>Ex5 5</li>
  </ul>
  
  <p>and Line_to_add.txt contains:</p>
  
  <ul>
  <li>This is a line</li>
  <li>This is another line just for kicks!</li>
  </ul>
  
  <p>I would like the output to be:</p>
  
  <ul>
  <li>Ex1 1</li>
  <li>Ex2 2</li>
  <li>Ex3 3</li>
  <li>This is a line</li>
  <li>This is another line just for kicks!</li>
  <li>Ex4 4</li>
  <li>Ex5 5</li>
  </ul>
  
  <p>tia :)</p>
  
  <h2>Solution</h2>
  
  <pre><code>@ECHO OFF
  FOR /F "tokens=*" %%A IN (Examples.txt) DO (
    ECHO %%A
    IF "%%A" EQU "Ex3" (
      TYPE Line_to_add.txt
    )
  ) &gt;&gt; temp.txt
  move /y temp.txt Examples.txt
  </code></pre>