1 @ECHO OFF 2 set name=test 3 if exist %name%\nul (echo 存在%name%文件夹) else if exist %name% (echo 存在%name%文件) else md %name%" 4 ping 127.1 -n 4 >nul
先判断是否存在文件夹,再判断是否存在文件,顺序如果调换的话会把文件夹当作文件处理了。