How to do a for loop in windows command line?

前端 未结 3 510
借酒劲吻你
借酒劲吻你 2021-01-30 13:37

I was wondering if this was possible? I\'m not familiar with using windows command line, but I have to use it for a project I\'m working on. I have a a number of files, for whic

3条回答
  •  一向
    一向 (楼主)
    2021-01-30 14:12

    This may help you find what you're looking for... Batch script loop

    My answer is as follows:

    @echo off
    :start
    set /a var+=1
    if %var% EQU 100 goto end
    :: Code you want to run goes here
    goto start
    
    :end
    echo var has reached %var%.
    pause
    exit
    

    The first set of commands under the start label loops until a variable, %var% reaches 100. Once this happens it will notify you and allow you to exit. This code can be adapted to your needs by changing the 100 to 17 and putting your code or using a call command followed by the batch file's path (Shift+Right Click on file and select "Copy as Path") where the comment is placed.

提交回复
热议问题