Command line DO in batch files

May 20, 2008
12,175
133
Syracuse, NY, USA
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
 

Similar threads