I am completely new to batch files and do simple commands. I figured out how to move text to another file, find a line, etc., but I want to add a few lines of text to an existing text file. Here is what I still have:
@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 Example.txt contains:
- Ex1 1
- Ex2 2
- Ex3 3
- Ex4 4
- Ex5 5
and Line_to_add.txt contains:
- This is a string
- This is another line for kicks!
I would like the result to be:
- Ex1 1
- Ex2 2
- Ex3 3
- This is a string
- This is another line for kicks!
- Ex4 4
- Ex5 5
tia :)
Decision
@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
source
share