windows - 如何使用 Windows cmd 在文本文件的每一行中添加一个字符串?

标签 windows batch-file cmd

我有一个很长的 list ,每一行都读着

p1 Title 1
p24 Title 2
p84 Title 3
...

我需要在每个文件前面加上一个简单的字符串,像这样的书的首字母。
MB.p1 Title 1
MB.p24 Title 2
MB.p84 Title 3
...

我已经尝试了 Batch file to add characters to beginning and end of each line in txt file 上的提示和 How do you loop through each line in a text file using a windows batch file?

最佳答案

就我而言,我发现最简单的方法是结合使用上面发布的两个链接:

for /f "tokens=*" %a in (input.txt) do (echo MB.%a) >> output.txt

关于windows - 如何使用 Windows cmd 在文本文件的每一行中添加一个字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32801741/

相关文章:

windows - 如何使用批处理/命令脚本一次从多个文件夹中删除文件名前缀?

Windows CMD - 如何使用 AM PM 创建时间变量

batch-file - 如何使用CMD重命名文件

c++ - 在 Windows 上使用带有 Cxx.jl 的 Julia 中的 boost 库

windows - 如何让 Vim 正确显示文件而不是显示 ^@ 字符

windows - 通过 curl 命令行发送到 github (Windows)

Windows 批处理脚本 : Parse CSV file and extract data

windows-7 - 在批处理文件中检查计算机是否已插入交流电源

merge - 按名称从文件列表中获取最新文件并将其与 Windows 批处理文件中的另一个文件合并?

windows - 批处理文件创建日志文件