![定义 0 个文件夹来执行子进程](https://linux22.com/image/1353093/%E5%AE%9A%E4%B9%89%200%20%E4%B8%AA%E6%96%87%E4%BB%B6%E5%A4%B9%E6%9D%A5%E6%89%A7%E8%A1%8C%E5%AD%90%E8%BF%9B%E7%A8%8B.png)
我如何定义 0(数字零)个文件夹位于当前目录中?我之所以问这个问题是因为在批处理程序中,我无法使此条件为真,以便转到 nofolder 子进程。
@echo off
set count=
for /d %%a in (*) do set /a count+=1
if %count%==0 (goto nofolder) else (goto display)
:nofolder
cls
echo No folders found
pause
goto end
:display
cls
echo One or more folders found
pause
goto end
答案1
%count%==0
永远不会为真,因为计数永远不会设置为零。
改成set count=
set "count=0"