%%a 是什么意思?(批)

Moo*_*orn 5 batch-file batch-processing

%%a 是什么意思?
我了解上下文,但不了解如何使用它。例如 :

FOR %%a in (%HELP%) DO echo I don't Know what it means
Run Code Online (Sandbox Code Playgroud)

Mon*_*aft 5

%%a 指的是您的 for 循环将写入的变量的名称。

引用自for /?

FOR %variable IN (set) DO command [command-parameters]

  %variable  Specifies a single letter replaceable parameter.
  (set)      Specifies a set of one or more files.  Wildcards may be used.
  command    Specifies the command to carry out for each file.
  command-parameters
             Specifies parameters or switches for the specified command.

To use the FOR command in a batch program, specify %%variable instead
of %variable.  Variable names are case sensitive, so %i is different
from %I.
Run Code Online (Sandbox Code Playgroud)

示例 1:

for %%a in (A B C D E) do Echo %%a
Run Code Online (Sandbox Code Playgroud)

生产

A
B
C
D
E
Run Code Online (Sandbox Code Playgroud)

示例 2:

for %%a in (A B C) do (for %%b in (1 2 3) do Echo %%a:%%b)
Run Code Online (Sandbox Code Playgroud)

生产

A:1
A:2
A:3
B:1
B:2
B:3
C:1
C:2
C:3
Run Code Online (Sandbox Code Playgroud)