help.hlp (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
FOR--Notes
Examples  Syntax
────────────────────────────────────────────────────────────────────────────
 
                                 FOR──Notes
 
Using the IN and DO keywords
 
IN and DO are not parameters, but they are required in the FOR command. If
you omit either of these keywords, MS-DOS displays an error message.
 
Using the replaceable variable
 
To avoid confusion with the batch parameters %0 through %9, you can use any
character for variable except the numerals 0 through 9. For simple batch
programs, a single character such as %%F may be all that is necessary.
 
You can use multiple values for variable in complex batch programs to
distinguish different replaceable variables. However, you cannot nest (add)
multiple FOR commands on the same command line.
 
Specifying a group of files
 
The set parameter can represent a single group of files or several groups of
files. You can use wildcards (* and ?) to specify a file set. The following
are valid file sets:
 
    (*.doc)
 
    (*.doc *.txt *.me)
 
    (jan*.doc jan*.rpt feb*.doc feb*.rpt)
 
    (ar??1991.* ap??1991.*)
 
When you use the FOR command, the first value in set replaces %%variable (or
%variable) and MS-DOS carries out the specified command in order to process
this value; this continues until MS-DOS has processed all the files (or
groups of files) that correspond to the value (or values) in set.
 
                                      ♦