

If step is negative, varname will be decreased by the absolute value of step with each loop, and the loop will stop when varname is less than end. This example displays the even numbers from 2 through 20:ĭO can also count down, rather than up. Next, DO adds to the value of varname either the value of step if BY step is specified, or 1, and repeats the compare and execute process until varname is greater than end.

If step is positive or not specified, and varname is less than or equal to end, DO executes the batch file lines up to the ENDDO. DO then begins the loop process by comparing the value of varname with the value of end. If varname already exists in the environment, it will be overwritten. DO creates an environment variable, varname, and sets it equal to the value start. DO varname = start TO end is similar to a "for loop" in programming languages like BASIC.You must use LEAVE or GOTO to exit such a loop. The batch file lines between DO and ENDDO are repeated count times. The number of times the current DO loop has been executed.ĭO can be used to create several different kinds of loops. DO does not quote returned names automatically, even if you included quotes in the original argument. The same restriction may apply to names returned in the DO variable, if you pass them to TCC internal commands, or other commands which require quoting filenames with white space. When you use DO on an LFN drive, you must quote any file names which contain white space or special characters. DO will append the following lines (in a batch file) or prompt you for more input (at the command line) until it gets a closing ). If the last argument on the line is a single (, it is interpreted as the beginning of a command group. For example:ĭo count=1 to 10 by 1 (echo count=%count) (There is no ENDDO statement in a single-line DO). To use them in aliases or at the prompt, you need to define the DO on a single line, and enclose the body of the DO loop in a command group following the DO expression. Use wildcards with caution on LFN volumes see LFN File Searches for details.ĭO can be used in batch files, aliases, or at the command prompt. Supports extended wildcards, ranges, and include lists for the set. Perform the loop in the current directory and all its subdirectories Like /L, but treats double quoted arguments (with embedded whitespace) as a single argument. Parse the output of the command, saving the next output line in varname each time the loop is executed. Members of set are strings, not filenames Loop through each character in expression

The loop termination time in 24-h hh:mm:ss format
#BATCH FILE CHOICE COMMAND AS TIMER ISO#
The loop termination date in ISO 8601 format If you use multiple commands, they must be separated by command separators or be placed on separate lines. One or more commands to execute each time through the loop. Wildcards are not interpreted.Ī file each line of which contains a string the loop is to be executed forĪ date, time, size or exclusion range. Integers in the range or internal variables or variable functions that evaluate to such values, controlling the number of times the loop is executed.Ī conditional expression to determine whether or not the loop should be executedĪ filename or list of filenames, possibly using wildcardsĪn arbitrary set of strings. The environment variable containing the current value of the loop index, or the current filename or string, or the current line from a file. Integer in the range, or an internal variable or variable function that evaluates to such a value, specifying the number of times the loop is executed.
