Deleting Empty File Folders

  • Thread starter Thread starter Steve
  • Start date Start date
S

Steve

Is there an easy way of deleting empty file folders in
windows or a third party program? We have made major
modifications to our data file stucture and would like to
eliminate all of the now empty folders.
 
Is there an easy way of deleting empty file folders in
windows or a third party program? We have made major
modifications to our data file stucture and would like to
eliminate all of the now empty folders.


@echo off
if {%1}=={} @echo Syntax DelMT Folder&goto :EOF
if not exist %1 @echo Syntax DelMT Folder - %1 not found.&goto :EOF
setlocal
set folder=%1
:loop
set delSW=N
for /f "Tokens=*" %%f in ('dir %folder% /AD /S /b') do (
set fld="%%f"
set MT=Y
call :IsMT
)
if "%delSW%" EQU "Y" goto :loop
endlocal
goto :EOF
:IsMT
for /f "Tokens=*" %%m in ('dir %fld% /a /b') do (
set MT=N
)
if "%MT%" EQU "N" goto :EOF
rd /q %fld%
set delSW=Y


Jerold Schulman
Windows: General MVP
JSI, Inc.
http://www.jsiinc.com
 
Back
Top