Instead of
using a single percent (%) symbol, you use two in front of the variable. Here??™s a sample of how you
can use this command in a batch file.
Echo Off
For %%F In (*.BAT *.TXT) Do Dir %%F /B
Echo On
In this case, the For command processes all of the files that have a BAT or TXT extension in the
current directory. The command processes the files in the order in which they appear in the directory
and you have no guarantee what the order is. The %%F variable contains the name of an individual
file. The Dir command is called once for each file with the %%F variable as an input. In
this case, the command outputs the filenames using the bare format, so you could use this batch file
to create a text file containing a list of files that match the criteria. Additional processing could
archive the files or do anything else that you might like. The For command provides the following
arguments.
{%Variable | %%Variable} Specifies a replaceable parameter; the argument that will
receive the individual members of a set. The replaceable parameter takes two forms. Use the
%Variable form when you want to use the replaceable parameter as input to another command
or utility.
Pages:
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380