windows 批处理脚本读取输入文本文件并为输入文本文件的每一行制作文本文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17648627/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 10:42:35  来源:igfitidea点击:

Batch script to read input text file and make text file for each line of input text file

windowsbatch-file

提问by user2582367

I am having an Input file in the location C:/temp/sample.txt, which consists of one word in each line of the text file. For supporting UI, I need each line to be displayed as text file in front end. So I want a batch script which will produce output as text files for each line of the input text file in the same folder. Can you please suggest whether it is possible to make it?

我在 location 中有一个 Input 文件C:/temp/sample.txt,它在文本文件的每一行中包含一个单词。为了支持 UI,我需要在前端将每一行显示为文本文件。所以我想要一个批处理脚本,它将为同一文件夹中输入文本文件的每一行生成作为文本文件的输出。你能建议是否有可能做到吗?

回答by bkausbk

It is possible with the "for" command:

可以使用“for”命令:

for /f %i in (input.txt) do echo. > %i

Use %%i in batch files instead of %i.

在批处理文件中使用 %%i 而不是 %i。

回答by Lo?c MICHEL

for /f %%i in (c:\temp\sample.txt) do echo %%i > c:\temp\%%i.txt