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

5

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

FOR %%a in (%HELP%) DO echo I don't Know what it means
1个回答

7

%%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.

范例1:

for %%a in (A B C D E) do Echo %%a

产生

A
B
C
D
E

例子2:

for %%a in (A B C) do (for %%b in (1 2 3) do Echo %%a:%%b)

生成

A:1
A:2
A:3
B:1
B:2
B:3
C:1
C:2
C:3

你会如何设置你想让for语句查找的变量? - Moonicorn
那似乎与您当前提出的问题非常不同。为什么不将其作为一个新问题提出呢?另外,如果您觉得我的回答有帮助,请将其标记为正确答案。 - Monacraft
欢迎,Monacraft。 - Moonicorn
@Moonicorn 谢谢,现在发布你的另一个问题,我会研究一下。 - Monacraft
您每90分钟只能发布一次... XD - Moonicorn

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接