Add 'Delete empty folders' to Windows context menu

前端 未结 2 483
北荒
北荒 2020-12-31 22:10

I\'d like to add to context menu this nice shell script that automatically deletes all empty folders and subfolders under the folder it is run from:

for /f \         


        
相关标签:
2条回答
  • 2020-12-31 22:34

    Thanks to Joey comment I was able to find the following solution.

    Step 1: create a file with reg extension (like for example add_delete_empty_folders_to_context_menu.reg) and put the following lines inside it:

    Windows Registry Editor Version 5.00
    
    [HKEY_CLASSES_ROOT\Directory\shell\Delete empty folders]
    
    [HKEY_CLASSES_ROOT\Directory\shell\Delete empty folders\Command]
    @="cmd /c for /f \"usebackq delims=\" %%d in (`\"dir \"%1\" /ad/b/s | sort /R\"`) do rd \"%%d\""
    

    Step 2: double click on your reg file and give all the needed confirmations.

    Now you have a handy Delete empty folders command in your context menu, popping up when you right-click on a directory. This works for me on Windows 7 and Windows 10.

    Avoid abuse of this functionality, some softwares need their empty folders to work properly.

    Follow up

    If you experience trouble (as Enora, see below) you can try to use the following line in the reg file, in place of the original one:

    @="cmd.exe /K for /f \"usebackq delims=\" %%d in (`\"dir \"%V\" /ad/b/s | sort /R\"`) do rd \"%%~d\""
    

    I actually don't know if this version is more robust, I just report here the solution found by Enora for her case.

    0 讨论(0)
  • 2020-12-31 22:51

    E ia ora na tatou

    Here is another way:

    Windows Registry Editor Version 5.00
    
    [HKEY_CLASSES_ROOT\Directory\shell\MenuDelZem]
    "MUIVerb"="Supprimer les dossiers vides"
    "Icon"="imageres.dll,-89"
    "ExtendedSubCommandsKey"="Directory\\ContextMenus\\MenuCmd"
    
    [HKEY_CLASSES_ROOT\Directory\background\shell\MenuDelZem]
    "MUIVerb"="Supprimer les dossiers vides"
    "Icon"="imageres.dll,-89"
    "ExtendedSubCommandsKey"="Directory\\ContextMenus\\MenuCmd"
    
    [HKEY_CLASSES_ROOT\Directory\ContextMenus\MenuCmd\shell\open]
    "MUIVerb"="Supprimez-les                                                                     
    0 讨论(0)
提交回复
热议问题