【发布时间】:2014-04-27 08:52:49
【问题描述】:
我正在尝试创建一个批处理脚本来记录找到的hello.txt 实例的位置。问题是我可以在%workingroot% 和/或%startingloc% 中都有一份hello.txt。
在脚本中,我试图让它检查它是否在%workingroot% 或%startingloc% 中。但是当它被触发并转到标签:skip 时,它似乎忘记了它仍在for 循环中,而是继续执行脚本。
for /f "delims=" %%f in ('dir /s /b /a-d "%searchloc%\hello.txt"') do (
if "%%f"=="%workingroot%" goto skip
if "%%f"=="%startingloc%" goto skip
echo Instance found.
set /a foundd=!foundd!+1
echo %%f>> "%templl%\wefound.txt"
:skip
)
有没有办法解决这个问题?
【问题讨论】:
-
您不想计算
%workingroot%和%startingloc%上的hello.txt 实例? -
不,我已经知道它们存在。
-
会不会是
%%f实际上从来没有%workingroot%或%startingpoint%值?你有回音%%ft 吗? -
你说得有道理——我现在就去检查一下。
-
原来他们不一样。我已经纠正了它,它现在可以正常工作了。谢谢! :)
标签: windows batch-file for-loop goto