In tip 8300, I scripted DelMT.bat to delete empty sub-folders in a directory tree.

Jim Long scripted DelMT.bat, making use of the SORT /Reverse command and suppressing errors, resulting in a much simpler solution.

DelMT.bat contains:

                              @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                              :: REMOVE EMPTY SUBFOLDERS                              for /f "tokens=*" %%A in ('dir /ad /s /b %Folder% ^|Sort /Reverse') do (                               RmDir "%%A" 2>NUL                              )                              :: REMOVE FOLDER, IF EMPTY                              RmDir %Folder% 2>NUL                              endlocal