Detect if your pathname is a directory

 
set A="D:\path\to\name"
 
call:IsDir %A%
IF %ERRORLEVEL% == 0 (
    echo "Directory found"
) ELSE (
    echo "Directory not found"
)
 
:IsDir
FOR /F "delims=" %%i IN ("%~1") DO SET MYPATH="%%~fi"
PUSHD %MYPATH% 2>NUL
IF ERRORLEVEL 0 (
    POPD
)
GOTO:EOF

TAGS : Tutorial DOS function Is Directory IsDir ERRORLEVEL FOR PUSHD POPD