简体   繁体   中英

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...)

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 . However, if you only want to delete empty directories, then you can do the following using 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM