我正在尝试创建一个批处理脚本,该脚本将记录找到的hello.txt
实例的位置。问题是我可能在hello.txt
和/或%workingroot%
中都有%startingloc%
的一个副本。
在脚本中,我尝试检查它是否在%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
)
有没有办法解决这个问题?
答案 0 :(得分:3)
for /f "delims=" %%f in ('dir /s /b /a-d "%searchloc%\hello.txt"') do (
if not "%%f"=="%workingroot%" if not "%%f"=="%startingloc%" (
echo Instance found.
set /a foundd=!foundd!+1
echo %%f>> "%templl%\wefound.txt"
)
)
应该适合你。