Empty

CMD Batch script to show if a folder is empty:

    @Echo off
    Setlocal
    if {%1}=={} set _empty=Syntax: %0 "" &goto :message

    ::Does folder exist
    if not exist %1 (
    	set _empty=No Such Folder
    	goto :message
    )

    :: Is folder empty
    set _TMP=
    for /f "delims=" %%a in ('dir /b %1') do set _TMP=%%a

    IF {%_TMP%}=={} (
    	set _empty=Empty
    ) ELSE (
    	set _empty=Not Empty
    )

    :message
    echo:
    Echo %_empty%
    echo:
    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-2016
Some rights reserved