% (Replaceable parameter)
The replaceable parameters %0 and %1 to %9 can be placed anywhere within a
batch file. When the batch file is run, %0 is replaced by the name of the
batch file, and the argument variables %1 to %9 are replaced by the
corresponding parameters entered on the command line. For example, to copy the contents of one folder to another, you would add
the following statement in your batch file: xcopy %1\*.* %2 When you run the file, you would type the following: mybatch.bat C:\afolder D:\bfolder. The effect is the same as if you had written xcopy C:\afolder \*.*
D:\bfolder in the batch file. The % parameter expands the batch script argument variables (%0, %1, ...,
%9) as follows: %* in a batch script is a wildcard reference to all the arguments.
For individual argument variables, the expansion options are explained in the
following tables.
The modifiers can be combined to get compound results:
In the above examples %1 and PATH can be replaced by other valid values.
The %~ syntax must be terminated by a valid argument number. The %~ modifiers
may not be used with %*. |