将文本添加到.txt文件中每行的开头 [英] Adding text to start of each new line in a .txt file

查看:331
本文介绍了将文本添加到.txt文件中每行的开头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在文本文件的每一行中添加预定义的文本,并使用添加的文本创建一个新的文本文件.请帮忙.

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.

推荐答案

在Windows中,可以这样做:

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

还请注意,如果不将>"放在%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.

这篇关于将文本添加到.txt文件中每行的开头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆