Adding text to every line in a .txt file

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
rasil
Posts: 31
Joined: 23 Apr 2020 13:05

Adding text to every line in a .txt file

#1 Post by rasil » 23 Jul 2020 16:20

hi,

I cannot figure out how to do the following:

make a batch file that puts batch code at the start of the text and at the end! example

<input.txt>
@echo off
echo hello!
pause

<output.txt>
echo @echo off >test.bat
echo echo hello! >test.bat
echo pause >test.bat

As you can see i am trying to make a batch file form an existing batch file but i do not want to put "echo" and ">test.bat" every start of and end of a line of code because my code could be 1000-5000 lines of code.

any help would be nice :D thanks!!

penpen
Expert
Posts: 1991
Joined: 23 Jun 2013 06:15
Location: Germany

Re: Adding text to every line in a .txt file

#2 Post by penpen » 24 Jul 2020 03:39

If you want to do it that way, you also have to escape multiple characters.
I would use the type-command (or the copy-command), if you want to do have with all lines:

Code: Select all

>>"test.bat" type "input.txt"
penpen

Post Reply