根据列表批量创建文本文件

Mac*_*Man 1 batch-file

我必须为工作场所的每台电脑创建一个文本文件,有没有办法从文本文件中的电脑列表中批量读取并为每行文本创建一个文本文件?

前任。文本文件

    Computer1
    Computer2
    Computer3
Run Code Online (Sandbox Code Playgroud)

我希望它创建一个computer1.txt、computer2.txt 和computer3.txt,但是对于大约400 台电脑的列表...这似乎很容易,我只是不确定如何将批处理文件链接在一起。我在学!:) 一如既往地感谢您的所有帮助!

Mat*_*son 5

@echo off
setlocal

for /f "tokens=*" %%a in (comps.txt) do (type nul>"%%a.txt")
Run Code Online (Sandbox Code Playgroud)

要将预定义文本添加到文件中,请执行以下操作:

for /f "tokens=*" %%a in (comps.txt) do (
  echo This is line 1 of text>"%%a.txt"
  echo This is line 2 of text>>"%%a.txt"
  echo This is line 3 of text>>"%%a.txt"
  echo This is line 4 of text>>"%%a.txt"
)
Run Code Online (Sandbox Code Playgroud)