@echo off setlocal if {%1}=={} set _empty=Syntax: empty.cmd "c:\Folder to check" &goto :message ::Does folder exist if not exist %1 set _empty=No Such Folder&goto :message :: Is folder empty :: The search for a random string should succeed without error, unless the directory is empty dir %1 /b | find /v "Some random string" >nul && (set _empty=Not Empty) || (set _empty=Empty) :message echo %_empty% endlocal&set _empty=%_empty%