Empty

CMD Batch script to show if a folder is empty:

@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
:: Search the filenames for a random string, this will complete without error unless the directory is empty.

Dir %1 /b | find /v "RandomString64" >nul && (set _empty=NotEmpty) || (set _empty=Empty)

:message
Echo %_empty%
Endlocal&set _empty=%_empty%

“The difference between false memories and true ones is the same as for jewels: it is always the false ones that look the most real, the most brilliant” ~ Salvador Dalí

Related:

IF command


© Copyright SS64.com 1999-2013
Some rights reserved