For Ü
ßßßß
Runs a command for a each in a list of files.
Syntax: FOR %var IN (list) DO command [options]
var The name of an environment variable. You will use this
variable in the options portion
list A list of files that will be acted upon
command A command to run against the list
options The options passed to the 'command'. In the 'options', you
may reference the 'var' from above, preceding it with '%'
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, FreeDOS displays an error message.
Specifying a group of files
The set parameter can represent a single group or several groups of
files. You can use wildcards (* and ?) to sepcify a file set. The
following are valid file sets:
(*.doc)
(*.doc *.txt *.c)
(hel*.c hel*.obj com*.c com*.c)
(read??.* re??me.*)
When you use for, the first value in set replaces %variable and FreeDOS
carries out the sepcified command in order to process this value; this
continues until FreeDOS has processed all the files that correspond to
the value (or values) in set.
Example:
In this example, each file with a .TXT or .C extension in the current
directory is substituted for the %f variable until the contents of every
file are displayed. To use this command in a batch file, replace every
occurence of %f with %%f.
for %f in (*.txt *.c) do type %f