如何做循环批处理? [英] how to do loop in Batch?
本文介绍了如何做循环批处理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要创建这样的事情
dup.bat infile outfile times
例如用法是
dup.bat a.txt a5.txt 5
它会创建文件a5.txt有A.TXT重复内容的5倍
at it would create file a5.txt that has the content of a.txt repeated 5 times
但我不知道如何为循环批量做,该怎么办呢?
however I do not know how to do for loop in batch, how to do it?
推荐答案
您可以做循环是这样的:
You can do the loop like this:
SET infile=%1
SET outfile=%2
SET times=%3
FOR /L %%i IN (1,1,%times%) DO (
REM do what you need here
ECHO %infile%
ECHO %outfile%
)
然后把输入文件,重复它,你可以使用更多
与重定向到输入文件的内容附加到输出文件。注意这是假定这些是文本文件。
Then to take the input file and repeat it, you could use MORE
with redirection to append the contents of the input file to the output file. Note this assumes these are text files.
@ECHO off
SET infile=%1
SET outfile=%2
SET times=%3
IF EXIST %outfile% DEL %outfile%
FOR /L %%i IN (1,1,%times%) DO (
MORE %infile% >> %outfile%
)
这篇关于如何做循环批处理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文