Adding text to start of each new line in a .txt fi

2019-07-14 02:09发布

I would like to add a predefined text to each new line on a text file and create a new text file with the added text. Please help.

1条回答
疯言疯语
2楼-- · 2019-07-14 02:45

In Windows, this will do it:

(for /f "delims=" %L in (oldfile.txt) do @echo predefined text %L)> newfile.txt

Note that in a batch file you'll need to use double % signs:

(for /f "delims=" %%L in (oldfile.txt) do @echo predefined text %%L)> newfile.txt

Note also that if you don't put the ">" right after the %L, you will get a space after every line. If you use ">>" instead of ">" you will keep adding on to newfile.txt instead of creating a new one each time you run it.

查看更多
登录 后发表回答