Trying to add text to the beginning of each line

Well here goes:

I tried to write a batch file that adds a specific fixed text to each line of an already existing text file.

for the adding text infront of each line I tried this:

for /F "delims=" %%j in (list.txt) do echo.STARTTEXT\%%j >> list.txt

for adding text after each line I haven't figured out how to do it.

HOWEVER:

When I use the code descripted, this:

1stline

becomes this ->>>

1stline
STARTTEXT1stline

I want it to be just

STARTTEXT1line

so to sum it up I want to add something BEFORE and AFTER the 1line (for each line in a text file), like this:

STARTTEXT1stlineENDTEXT
STARTTEXT2ndlineENDTEXT
STARTTEXT3rdlineENDTEXT
...

Any help is appreciated

use the below script to add text infront of each line :

sed 's/^/STARTTEXT/g' filenmae > output_file

Please note: This question is in the "Windows & Dos..." forum. A Unix-like answer may not be appropriate here.

Having said that, and in the absence of a batch script answer, sed is available for Windows:

sed for Windows

so... without sed it is impossible ?

With Windows scripting, it always helps to mention the exact version of Windows and whether you have installed any extended Windows scripting products and whether you have any programming languages installed.

Well I got Windows 7 Ultimate 32 bit.

No additional extended scripting products installed.

if sed is the only way I'd take an example for that aswell.

Thanks

The issue is that you are attempting to read the same file as you are writing. You can go ahead and use the code you wrote but instead of writing to the same file, write to a temporary file and then copy it over the original file

for /F "delims=" %%j in (list.txt) do echo.STARTTEXT\%%j >> tempfile.txt
 
followed by 
copy /Y tempfile.txt list.txt