|
FOR
Runs a specified command for each file in a set of files.
Syntax
FOR %%parameter IN (set) DO command
%%parameter Represents a replaceable parameter. Variables
are case-sensitive and must be represented with an alpha
value, such as %A, %B, or %C.
If you are using the FOR command at the command line rather
than in a batch program, specify %parameter instead of
%%parameter.
( set ) : Specifies one or more files, directories, range
of values, or text strings that you want to
process with the specified command.
command : Specifies the command that you want to carry out
on each file, directory, range of values, or
text string included in the specified (set).
Environment variables within a FOR loop are expanded at the
beginning of the loop and won't change until AFTER the end
of the DO section.
Examples
To display the contents of all the files in the current
directory that have the extension .doc or .txt using the
replaceable variable %f, type:
for %f in (*.doc *.txt) do type %f
Cmd Commands
|