批量创建基于列表的文本文件 [英] Have a batch create text files based on a list

查看:78
本文介绍了批量创建基于列表的文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须在工作场所为每台PC创建一个文本文件,是否可以从文本文件中的PC列表中批量读取并为每一行文本创建一个文本文件?

I've got to create a text file for each PC at my workplace is there a way to have a batch read from a list of PCs in a text file and create a text file for each line of text?

例如 文字文件

    Computer1
    Computer2
    Computer3

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

I want it to create a computer1.txt, computer2.txt, and computer3.txt, but for a list of about 400 PCs... It seems pretty easy I'm just not sure how to link batch files together. I'm learning! :) Thanks for all your help, as always!

推荐答案

@echo off
setlocal

for /f "tokens=*" %%a in (comps.txt) do (type nul>"%%a.txt")

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

To add a pre-defined text to the file, do something like this:

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"
)

这篇关于批量创建基于列表的文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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