For parameter % variable name in (related file or command) Do Command executed
Parameters: For has four parameters/D/L/R/f. Their functions are explained in the following example:
% Variable name: this variable name can be a single lowercase A-Z or an uppercase A-Z, they are case sensitive ~, For will give each read value to him!
In: Command Format. Just write it!
(Related file or command): For reads something and assigns it to the variable. If you do not understand it, refer to the following example.
Do: Command Format. Just write it!
The command to be executed: This is where you want to perform any operation on the value of each variable.
You can enter for/in cmd /? See the help provided by the system! I will also give it here for your reference.
For % variable in (SET) do command [command-parameters]
% Variable specifies a single letter replaceable parameter.
(SET) specifies one or more files. Wildcard characters can be used.
Command specifies the Command executed on each file.
Command-Parameters
Specify parameters or command line switches for specific commands.
Now let's start with the meaning of each parameter.
1. Parameter/d
If the set contains wildcards, it is specified to match the directory name instead of the file name.
2. Parameter/R
Currently, all file names in the specified path are read. Note that the file name
@ Echo off
For/R c: \ % I in (*. EXE) Do echo % I
Pause
Let's save the bat to drive D and execute it at will. I will see that he put the C root directory, and all the EXE files under each subdirectory are listed !!!!
3. Parameter/L
This set indicates a sequence of numbers from start to end in incremental form.
(, 5) will generate the sequence 1 2 3 4 5, (5,-) will generate the sequence (5 4 3 2 1 ).
@ Echo off
For/L % I in (1, 1, 5) do start cmd
Pause
Supports dos cyclic batch processing to intelligently process files. Batch compress to custom extension files
@ Echo off
For/R "e: \ test" % d in (*. DB) do zip % ~ Nd. Custom suffix % ~ Nd. DB
Pause