[Solved] Script to delete empty folders ?

Discussion in 'Scripting' started by ceo54, Mar 22, 2021.

  1. ceo54

    ceo54 MDL Addicted

    Aug 13, 2015
    867
    361
    30
    Hi,

    Does anyone has any scripts to delete the empty folder and subsequent empty folders inside those folders from the path script is run from ??

    Or any program that does this ?

    Any help will be greatly appreciated.

    Thanks.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. EXO56

    EXO56 MDL Member

    Mar 22, 2013
    183
    251
    10
    / Command-Line:
    Code:
    for /f "usebackq delims=" %%d in (`"dir /ad/b/s | sort /R"`) do rd "%%d"
    pause
    Remove 'pause' if you don't want any output (except errors).
    Script could have some limitations removing folders with Unicode characters.

    / Programs that can do the same: Empty Folder Nuker - RED (Remove Empty Directories) - ...
    Those are dedicated programs for such functions, but other files managers can do this too with some settings and their own internal commands.

    / PowerShell and VB Scripts : are also available just google for it.
     
  3. ceo54

    ceo54 MDL Addicted

    Aug 13, 2015
    867
    361
    30

    Empty Folder Nuker, this will do it. Thanks!
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...