batchfile: create output file w/ empty folder

February 21, 2011 at 18:07:40
Specs: Windows XP
Hi!

I need to determine empty folders within a given file location (e.g. C:\test\) and output the empty folder file names to an output file (e.g. C:\test\output.txt).

I have this code for the batch file however I can only echo ALL the folders to the txt file. I only need the empty folder file names to be echoed.

pushd C:\test
for /d %%d in (*) do (
rd /q %%d
echo %%d >> c:\test\output.txt
)
popd

Can someone assist me with this?

Thanks!


See More: batchfile: create output file w/ empty folder

Report •

#1
February 22, 2011 at 09:08:10
@echo off 
pushd \test
type nul > output.txt
for /D %%j in (*) do (
  dir /B "%%j" > empty.tmp
  for %%z in (empty.tmp) do if %%~zz equ 0 (
    echo.%%j>> output.txt
    rd /Q "%%j"
  )
)
del empty.tmp
popd


Report •
Related Solutions


Ask Question