批处理文件goto无法在for循环中使用 [英] Batch file goto not working in for loop
本文介绍了批处理文件goto无法在for循环中使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的批处理文件中有一个for循环,该循环遍历文件夹.我想跳过特定的文件夹.我可以使用IF语句来做到这一点,但更喜欢像下面显示的GOTO.
I have a for loop in my batch file that loops through folders. I want to skip particular folders. I can do this with an IF statement, but would prefer a GOTO like I'm showing below.
for /d %%F in (*) do (
if /i "%%F"=="Archive" goto nextFolder
REM do stuff here
:nextFolder
)
但是上面的错误给了我
) was unexpected at this time
推荐答案
这是行不通的-您不能将跳入控制流构造并期望一切都很好.
This won't work - you can't jump into a control-flow construct and expect everything to be fine.
请查看(Windows批处理)转到if block的行为很奇怪很好地讨论了为什么这是一个糟糕的主意.
Please take a look at (Windows batch) Goto within if block behaves very strangely for a good discussion of why this is a terrible idea.
这篇关于批处理文件goto无法在for循环中使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文