I am trying to check if the path defined in the program is file or a folder using batch file. Everything is working fine but when I try to give a path that isn't file or folder or doesn't have permission to access it, it gives output saying "it is a File".
Here is the code.
@ECHO off
SETLOCAL ENABLEEXTENSIONS
set ATTR=D:\Download\Documents\New
dir /AD "%ATTR%" 2>&1 | findstr /C:"Not Found">NUL:&&(goto IsFile)||(goto IsDir)
:IsFile
echo %ATTR% is a file
goto done
:IsDir
echo %ATTR% is a directory
goto done
:done