【发布时间】:2015-06-20 20:52:03
【问题描述】:
在本网站贡献者的大力帮助下,我使用 DOS 命令编写了一个 FOR 循环,这样使用 FOR 命令的一个批处理文件 (Fred) 使用其他命令执行第二个批处理文件 (Barney) 以复制模板文件 (如下)
弗雷德.bat:
REM Call Barney.bat to run the copy file command in Barney three times
for /l %%i in (1,1,3) DO Barney.bat %%i
REM now make another copy
copy wilma3.txt to wilma4.txt
巴尼.bat:
REM make %i-th copy of the file fred.txt as wilma%i.txt
copy fred.txt wilma%1.txt
这两个文件(Fred 和 Barney)可以很好地根据需要创建三个副本(wilma1.txt、wilma2.txt 和 wilma3.txt)。但是,一个三个副本的焦点似乎没有返回到第一个批处理文件(Fred),所以可以执行“将 wilma3.txt 复制到 wilma4.txt”这一行吗?有没有办法产生这个结果?也许我应该只在一个批处理文件而不是两个文件中进行循环复制?
【问题讨论】:
标签: windows batch-file for-loop cmd