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:
@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 >> Examples.txt
  )
)
if Examples.txt contains:
- Ex1 1
 - Ex2 2
 - Ex3 3
 - Ex4 4
 - Ex5 5
 
and Line_to_add.txt contains:
- This is a line
 - This is another line just for kicks!
 
I would like the output to be:
- Ex1 1
 - Ex2 2
 - Ex3 3
 - This is a line
 - This is another line just for kicks!
 - Ex4 4
 - Ex5 5
 
tia :)
Solution
@ECHO OFF
FOR /F "tokens=*" %%A IN (Examples.txt) DO (
  ECHO %%A
  IF "%%A" EQU "Ex3" (
    TYPE Line_to_add.txt
  )
) >> temp.txt
move /y temp.txt Examples.txt