循环/D标志的批处理文件未出现在命令行中 [英] Batch file for loop /D flag not appearing in command line
问题描述
我有一个小的批处理文件,我想将其从一个位置复制到许多可能具有不同名称的位置.
I've got a small batch file that I want to use to copy a file from one location to many locations that may have different name.
for /D %%f in ("%%localappdata%%\Microsoft\Opc*") do (
for /D %%x in ("%%f\*") do (copy /y user.config %%x\)
)
我能够使它在命令行中正常运行,但是如果我尝试运行批处理脚本,那么这就是命令行中显示的全部内容:
I'm able to get this to run fine in the command line, but if I try and run my batch script instead, this is all that's shown on the command line:
for / %f in ("%localappdata%\Microsoft\Opc*") do (
for / %x in ("%f\*") do (copy /y user.config %x\ )
)
无论出于何种原因,/D标志似乎都变成了/
It looks like, for whatever reason, the /D flag is getting changed into just /
我对批处理脚本还很陌生,因此任何帮助将不胜感激!
I'm rather new to batch scripting, so any help would be greatly appreciated!
推荐答案
在批处理脚本中:与(正确)将%%f
和%%x
参数中的%
百分号加倍相反,请勿将%
翻倍在诸如%localappdata%
等的环境变量名称中...
In a batch script: contrary to (correct) doubling the %
percent sign in %%f
and %%x
parameters, do not double %
in environment variable names like %localappdata%
etc...
for /D %%f in ("%localappdata%\Microsoft\Opc*") do (
for /D %%x in ("%%f\*") do (copy /y user.config %%x\)
)
但是,回显的令人惊叹的 /
而不是/D
不应影响for /D
命令的功能(仍在搜索说明).
However, that stunning /
echoed instead of /D
should not affect the for /D
command functionality (still searching for an explanation).
这篇关于循环/D标志的批处理文件未出现在命令行中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!