05-判断是文件还是文件夹

@echo off &title 判断是文件或文件夹

call :GetPathType D:\System\桌面\BatDir\menu\bin
call :GetPathType D:\System\桌面\BatDir\menu\add_background_menu.bat
call :GetPathType D:\System\桌面\BatDir\menu\xxx

pause
exit /b

:GetPathType
if exist "%~1" (
    if exist "%~1\*" ( REM %~1\
        echo folder &exit /b 0
    ) else (
        echo file &exit /b 1
    )
) else (
    echo path "%~1" not exist &exit /b 2
)
goto :eof

 

posted @ 2025-09-07 16:26  乐观的知觉  阅读(6)  评论(0)    收藏  举报