Computer and Software Support

DOS Command For

Type: Internal (2.0 and later)


FOR %%(variable) IN set DO (command)
or for interactive processing
FOR %%(variable) IN set DO (command)

Purpose: Performs repeated execution of commands (for both batch processing and interactive processing).



%% variable can be any character.

set can be one or more file specifications.

The %%variable is set sequentially to each of the set entries. Then the DOS command specified after the DO is carried out. Typically set will include wildcard characters (? and *) to indicate a group of filenames. Then, %%variable is set to each matching filename. You can also use path designations for set.

This command provides a way to repeat DOS commands in a predetermined way (usually to tell DOS to carry out a command on each of the files named in the set specifications).

Any character except 0 through 9 can be used for %%variable (to avoid confusion with the %0-%9 batch parameters).



To TYPE (display) the contents of every file in the current directory that has the filename extension TXT, enter

for %%X in (*.txt) do type %%X

If the program finds files on the disk that have the TXT extension, the command sets %%X to each of the TXT files, then displays the contents of each file.

This page is from I pasted it on my website to avoid possible broken links. For further help with DOS commands, Check out.