批处理文件在txt文件的每一行的开头和结尾添加字符 [英] Batch file to add characters to beginning and end of each line in txt file
问题描述
我有一个文本文件,我想知道有人有一个批处理文件可以在文本文件的每一行的末尾添加到 beninning 和"?
I have a text file, I was wondering anyone have a batch file to add " to the beninning and ", at the end of each line in a text file?
例如我有
1
2
3
我想要
"1",
"2",
"3",
如果有人可以粘贴一个快速的,它会帮助我=)
If some could paste a quick one it would help me out =)
编辑(从评论到@mastashake57 的帖子):
EDIT (from comment to @mastashake57's post):
我在 Windows 上,如果感觉就像我在要求某人做这件事,我很抱歉,这就是我所拥有的.
Im on windows, My appologies if it felt like i was asking someone to do it, This is what I have.
@echo off
setlocal
set addtext=test
for /f "delims=" %%a in (list.txt) do (echo/|set /p =%%a%addtext% & echo & echo) >>new.txt
但我不知道如何放置逗号,因为它认为它是我假设的命令的一部分或类似的东西.这只会在每行的字体中放置文本.
But I cant figure out how to put commas as it thinks its part of the command I assume or something of that sort. This only places text in the font of each line.
推荐答案
@echo off
setLocal EnableDelayedExpansion
for /f "tokens=* delims= " %%a in (input.txt) do (
set /a N+=1
echo ^"%%a^",>>output.txt
)
-joedf
这篇关于批处理文件在txt文件的每一行的开头和结尾添加字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!