将“删除空文件夹”添加到Windows上下文菜单 [英] Add 'Delete empty folders' to Windows context menu

查看:73
本文介绍了将“删除空文件夹”添加到Windows上下文菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在上下文菜单中添加此漂亮的shell脚本,该脚本会自动删除该文件夹下的所有空文件夹和子文件夹文件夹运行来源:

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 "usebackq delims=" %%d in (`"dir /ad/b/s | sort /R"`) do rd "%%d"

要添加这样的项目到(目录)上下文菜单,我应该运行扩展名为 reg 的文件,其内容类似于

To add such an item to (directories) context menu I should run a file with reg extension having a content similar to

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\Delete empty folders]

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

,但这不起作用。

推荐答案

感谢乔伊(Joey)评论,我得以找到以下内容:解决方案。

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

步骤1:创建扩展名为 reg 的文件(例如 add_delete_empty_folders_to_context_menu .reg )并在其中添加以下行:

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\""

步骤2:双击 reg 文件并给出所有需要的确认。

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

现在您有了一个方便的删除空文件夹命令,右键单击目录会弹出。在Windows 7和Windows 10上我可以使用。

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.

跟进

如果遇到麻烦(如Enora,请参见下文),则可以尝试使用以下行在 reg 文件中,代替原始文件:

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\""

我实际上不知道如果此版本更强大,我只需在此处报告Enora为她的案例找到的解决方案

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

这篇关于将“删除空文件夹”添加到Windows上下文菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆