在 Windows 中删除大文件夹的最快方法是什么?
我想删除一个包含数千个文件和文件夹的文件夹。 如果我使用 Windows 资源管理器删除该文件夹,可能需要 10-15 分钟(并非总是如此,但经常)。 Windows 中有没有更快的方法来删除文件夹?
其他细节:
- 我不关心回收站。
- 这是一个 NTFS 驱动器。
I want to delete a folder that contains thousands of files and folders. If I use Windows Explorer to delete the folder it can take 10-15 minutes (not always, but often). Is there a faster way in Windows to delete folders?
Other details:
- I don't care about the recycle bin.
- It's an NTFS drive.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
最糟糕的方法是发送到回收站:您仍然需要删除它们。 其次最糟糕的是使用 Windows 资源管理器执行 Shift+Delete:它会浪费大量时间在开始删除任何内容之前检查内容。
接下来最好的方法是从命令行使用 rmdir /s/q 文件夹名称 。
del /f/s/qfoldername
也很好,但它留下了目录结构。我发现的最好的是一个两行批处理文件,第一遍删除文件并输出到 nul,以避免为每个单个文件写入屏幕的开销。 然后,第二遍清理剩余的目录结构:
这比单个 rmdir 快近三倍,基于 Windows XP 加密磁盘的时间测试,删除约 30GB/1,000,000 个文件/15,000 个文件夹:
rmdir
大约需要 2.5 小时,del+rmdir
大约需要 53 分钟。 更多信息请访问超级用户。这对我来说是一项常规任务,因此我通常将需要删除的内容移至 C:\stufftodelete 并将这些
del+rmdir
命令放在 deletestuff.bat 批处理文件中。 这计划在晚上运行,但有时我需要在白天运行它,所以越快越好。可以找到
del
命令的 Technet 文档 这里。 有关上面使用的参数的附加信息:/f
- 强制(即删除文件,即使它们是只读的)/s
- 递归/包含子文件夹(此定义来自 < a href="https://ss64.com/nt/del.html" rel="noreferrer">SS64,因为 technet 只是声明“指定文件”,这没有帮助)。/q
- 安静(即不提示用户确认)rmdir
的文档 此处。 参数为:/s
- 递归(即与 del 的 /s 参数相同)/q
- 安静(即与 del 的 /q 参数相同)The worst way is to send to Recycle Bin: you still need to delete them. Next worst is shift+delete with Windows Explorer: it wastes loads of time checking the contents before starting deleting anything.
Next best is to use
rmdir /s/q foldername
from the command line.del /f/s/q foldername
is good too, but it leaves behind the directory structure.The best I've found is a two line batch file with a first pass to delete files and outputs to nul to avoid the overhead of writing to screen for every singe file. A second pass then cleans up the remaining directory structure:
This is nearly three times faster than a single rmdir, based on time tests with a Windows XP encrypted disk, deleting ~30GB/1,000,000 files/15,000 folders:
rmdir
takes ~2.5 hours,del+rmdir
takes ~53 minutes. More info at Super User.This is a regular task for me, so I usually move the stuff I need to delete to C:\stufftodelete and have those
del+rmdir
commands in a deletestuff.bat batch file. This is scheduled to run at night, but sometimes I need to run it during the day so the quicker the better.Technet documentation for
del
command can be found here. Additional info on the parameters used above:/f
- Force (i.e. delete files even if they're read only)/s
- Recursive / Include Subfolders (this definition from SS64, as technet simply states "specified files", which isn't helpful)./q
- Quiet (i.e. do not prompt user for confirmation)Documentation for
rmdir
here. Parameters are:/s
- Recursive (i.e. same as del's /s parameter)/q
- Quiet (i.e. same as del's /q parameter)使用 Windows 命令提示符:
使用 Powershell:
请注意,在更多情况下,
del
和rmdir
会给您留下剩余文件,而 Powershell 会设法删除这些文件。Using Windows Command Prompt:
Using Powershell:
Note that in more cases
del
andrmdir
wil leave you with leftover files, where Powershell manages to delete the files.使用免费工具fastcopy。
它有一个删除选项,比 Windows 删除文件的方式快得多。
use fastcopy, a free tool.
it has a delete option that is a lot faster then the way windows deletes files.
按照建议使用命令提示符。 我不久前就弄清楚了为什么资源管理器这么慢,它可以让您估计删除文件/文件夹需要多长时间。 为此,它必须扫描物品的数量和尺寸。 这需要很长时间,因此对于大文件夹的等待是可笑的。
此外,如果文件存在特定问题,资源管理器将停止,
use the command prompt, as suggested. I figured out why explorer is so slow a while ago, it gives you an estimate of how long it will take to delete the files/folders. To do this, it has to scan the number of items and the size. This takes ages, hence the ridiculous wait with large folders.
Also, explorer will stop if there is a particular problem with a file,
要删除大量文件夹,您还可以使用发布的命令 spdenne 创建批处理文件。
1) 创建一个包含以下内容的文本文件,将引号中的文件夹名称替换为您的文件夹名称:
2) 使用 .bat 扩展名保存批处理文件(例如,deletefiles.bat)
3)打开命令提示符(开始>运行>Cmd)并执行批处理文件。 您可以从命令提示符执行此操作(用 X 替换驱动器号):
and to delete a lot of folders, you could also create a batch file with the command spdenne posted.
1) make a text file that has the following contents replacing the folder names in quotes with your folder names:
2) save the batch file with a .bat extension (for example deletefiles.bat)
3) open a command prompt (Start > Run > Cmd) and execute the batch file. you can do this like so from the command prompt (substituting X for your drive letter):
尝试Shift + 删除。 2 分钟内为我处理了 24.000 个文件。
Try Shift + Delete. Did 24.000 files in 2 minutes for me.