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 would replace every occurrence of %F with %%F. Otherwise, MS-DOS ignores the variable and displays an error message. MS-DOS 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: