Command line DO in batch files

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
#1
Some of the syntaxes work. This one screws up:

Code:
do i=1 to 5
    echo foo
    set /a due=%_datetime + 1
    do until datetime %due ( delay /m 1 )
    echo xxx
enddo
"xxx" is never seen. [Note, adding 1 to a datetime doesn't work when going around "minute corners" so don't try the test above just before a new minute.]

Oddly, you can fix it with

Code:
    do until datetime %due ( delay /m 1 )
    enddo
    echo xxx