[英]Fastest way to delete a tree of directories in batch file
I need to write a batch file that received a directory that contains a huge number of empty sub-directories and deletes them all. 我需要编写一个批处理文件,该文件接收到包含大量空子目录的目录并将其全部删除。
What's the fastest way of doing this? 这样做的最快方法是什么? (by fast I mean not like what Windows Explorer does when you try to delete such a directory...) (快速我的意思是不喜欢Windows资源管理器在您尝试删除此类目录时所执行的操作...)
Clarification: 澄清:
I'm not trying to delete only empty directories. 我不是要删除只有空目录。 It just so happens that this dir I'm trying to delete is mostly empty sub-dirs. 事实上,我试图删除的这个目录大多是空的子目录。
rd yourdirname /s/q
无论他们是否空无足,都能胜任。
I'm not sure if I understood the question. 我不确定我是否明白这个问题。 If you just want to delete the tree then you can just use rd /s
. 如果您只想删除树,那么您可以使用rd /s
。 However, if you only want to delete empty directories, then you can do the following using Cygwin. 但是,如果您只想删除空目录,则可以使用Cygwin执行以下操作。
find -type d -empty | xargs rmdir
The standard IT build where I work has Cygwin installed, and I've used this more than once. 我工作的标准IT构建安装了Cygwin,并且我不止一次使用过它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.