Check if a given path leads to a folder or a file:
@Echo off SETLOCAL Set _attr=%~a1 Set _isdir=%_attr:~0,1% If /I "%_isdir%"=="d" ( Echo %1 is a directory Exit /b 0 ) Echo %1 is NOT a directory Exit /b 2
Adapted from this StackOverflow answer.
c:\> IsDirectory.cmd "C:\docs\example folder"
"C:\docs\example folder" is a directory
c:\> IsDirectory.cmd C:\demo >NUl
c:\> If %errorlevel% EQU 2 Echo Demo folder not found
“The time you enjoy wasting is not wasted time” ~ Bertrand Russell
How-to: Parameters - Command Line Arguments %1 %~f1
ATTRIB - Extended Attributes.
PowerShell:
Get-ChildItem -directory