For--Examples
Suppose you want to use the type command to display the contents of all the files in the current directory that
have the extension .DOC or .TXT. To do this and to use the replaceable
variable %f, type the following command at the command prompt:
for %f in (*.doc *.txt) do type %f
In this example, each file that has the .DOC or .TXT 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, you simply replace every occurrence of %f with %%f. Otherwise, Windows NT ignores the variable and displays an error message.
Windows NT supports command switches, pipes, and redirection that you may want
to use with the specified command. For example, to redirect the output of the
previous example to PRN (the default printer port), you would type the
following command:
for %f in (*.doc *.txt) do type %f > prn:
More Information About For
For--Notes
For