The default way to check whether a directory exists in a Windows batch file (.cmd) is
if not exist "%directory%\nul" ( echo %directory% does not exist )
However, as this MS KB explains, the check for the NUL file does not work with directories on network drives mapped to a drive letter.
A working solution I found is to process the ERRORLEVEL value a DIR command sets
dir %directory% >nul 2>nul if errorlevel 1 ( echo %directory does not exist )
dir %directory% >nul 2>nul if not errorlevel 1 ( echo %directory exists )