为什么在批处理脚本不工作的"做好设置"功能? [英] why in batch script do not working the "do set" function?
本文介绍了为什么在批处理脚本不工作的"做好设置"功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在批次脚本以下问题。
I have the following problem in batch scripting.
我有这样的code线
for /f "tokens=*" %%d in ('dir /b /s a2lfiles_merger*.txt') do set merger_list=%%d
echo %merger_list%
和结果是回声是关闭
然后我想这code
for /f "tokens=*" %%d in ('dir /b /s a2lfiles_merger*.txt') do echo %%d
结果是 C:\\用户\\用户\\桌面\\编译\\输入\\ JOB_1 \\ a2lfiles_merger.txt
所以,问题是,为什么我不能设置与路径的变量?我需要在接下来的步骤来使用它,现在我被困在这种情况下。任何人都可以找到解决的办法?谢谢大家提前!
So, the question is why i cannot set a variable with the path? I need to use it in the next steps and now i am stuck in this situation. Can anyone find a solution ? Thank you all in advance!
推荐答案
修改code:
setlocal enabledelayedexpansion
for /f "tokens=*" %%d in ('dir /b /s a2lfiles_merger*.txt') do (
set merger_list=%%d
echo !merger_list!
)
注意SETLOCAL命令和括号包围的命令中的for循环被执行。这是怎样的循环工作。
note the setlocal command and the parenthesis enclosing the commands to be executed in the for-loop. that's how for loops work.
希望帮助!
这篇关于为什么在批处理脚本不工作的"做好设置"功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文