且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

实现一个for循环或while循环在windows MD-DOS批处理文件做

更新时间:2022-02-08 21:43:13

一个for循环由以下几部分组成:

A for loop consists of these parts:

计数循环结果的数量-A变量
- 实际内容的结果
-A线递增循环计数器变量结果
-an如果这样做一个GOTO跳出循环语句,如果循环计数器已经超过某个值结果
-A GOTO该进到循环的开始

-A variable for counting the number of loops
-Actual content
-A line that increments the loop counter variable
-An if statement that does a GOTO out of the loop if loop counter has exceeded some value
-A GOTO that goes to the beginning of the loop

set /p count = 0
:loopstart
doStuff
set count = count + 1
if %count%==10 GOTO loopend
GOTO loopstart

一个while循环是一样的东西,除了没有计数循环计数器,你代替其他一些条件,如如果选项%==%跳槽GOTO loopend

A while loop is the same thing, except instead of counting a loop counter, you substitute some other conditional such as if %option%=="quit" GOTO loopend

希望你能得到你基于这种信息想要什么。很抱歉,如果我的语法是不完美的,我不经常使用批处理文件。

Hope you can get what you want based on this info. Sorry if my syntax isn't perfect, I don't use batch files very often.