在 Windows 中删除大文件夹的最快方法是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/186737/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 05:30:42  来源:igfitidea点击:

What's the fastest way to delete a large folder in Windows?

windowswindows-xpfile-management

提问by BrezzaP

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?

我想删除一个包含数千个文件和文件夹的文件夹。如果我使用 Windows 资源管理器删除文件夹可能需要 10-15 分钟(不总是,但经常)。Windows 中是否有更快的方法来删除文件夹?

Other details:

其他详情:

  • I don't care about the recycle bin.
  • It's an NTFS drive.
  • 我不在乎回收站。
  • 这是一个 NTFS 驱动器。

回答by Hugo

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.

最糟糕的方法是发送到回收站:您仍然需要删除它们。下一个最糟糕的是使用 Windows 资源管理器进行 shift+delete:在开始删除任何内容之前,它会浪费大量时间检查内容。

Next best is to use rmdir /s/q foldernamefrom the command line. del /f/s/q foldernameis good too, but it leaves behind the directory structure.

接下来最好是rmdir /s/q foldername从命令行使用。del /f/s/q foldername也很好,但它留下了目录结构。

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:

我发现的最好的是两行批处理文件,第一遍删除文件并输出到 nul 以避免为每个单个文件写入屏幕的开销。然后第二遍清理剩余的目录结构:

del /f/s/q foldername > nul
rmdir /s/q foldername

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: rmdirtakes ~2.5 hours, del+rmdirtakes ~53 minutes. More info at Super User.

根据对 Windows XP 加密磁盘的时间测试,这比单个 rmdir 快近三倍,删除约 30GB/1,000,000 个文件/15,000 个文件夹:rmdir需要约 2.5 小时,del+rmdir需要约 53 分钟。更多信息在超级用户

This is a regular task for me, so I usually move the stuff I need to delete to C:\stufftodelete and have those del+rmdircommands 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.

这对我来说是一项常规任务,因此我通常将需要删除的内容移动到 C:\stufftodelete 并将这些del+rmdir命令放在 deletestuff.bat 批处理文件中。这计划在晚上运行,但有时我需要在白天运行,所以越快越好。

Technet documentation for delcommand can be found here. Additional info on the parameters used above:

del命令的Technet 文档可以在此处找到。关于上面使用的参数的附加信息:

  • /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)
  • /f- 强制(即删除文件,即使它们是只读的)
  • /s- 递归/包含子文件夹(这个定义来自SS64,因为技术网只是声明“指定的文件”,这没有帮助)。
  • /q- 安静(即不提示用户确认)

Documentation for rmdirhere. Parameters are:

rmdir此处的文档。参数是:

  • /s- Recursive (i.e. same as del's /s parameter)
  • /q- Quiet (i.e. same as del's /q parameter)
  • /s- 递归(即与 del 的 /s 参数相同)
  • /q- 安静(即与 del 的 /q 参数相同)

回答by Stephen Denne

Use Windows Command Prompt:

使用 Windows 命令提示符:

rmdir /s /q folder

回答by BrezzaP

use fastcopy, a free tool. it has a delete option that is a lot faster then the way windows deletes files.

使用fastcopy,一个免费工具。它有一个删除选项,比 Windows 删除文件的方式要快得多。

回答by nicodemus13

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,

此外,如果文件存在特定问题,资源管理器将停止,

回答by nicodemus13

and to delete a lot of folders, you could also create a batch file with the command spdenne posted.

要删除很多文件夹,您还可以使用发布的命令 spdenne 创建一个批处理文件。

1) make a text file that has the following contents replacing the folder names in quotes with your folder names:

1)制作一个文本文件,其中包含以下内容,用您的文件夹名称替换引号中的文件夹名称:

rmdir /s /q "My Apps"  
rmdir /s /q "My Documents"  
rmdir /s /q "My Pictures"  
rmdir /s /q "My Work Files"

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

2) 以 .bat 扩展名保存批处理文件(例如 deletefiles.bat)
3) 打开命令提示符(开始 > 运行 > Cmd)并执行批处理文件。您可以从命令提示符执行此操作(用 X 代替您的驱动器号):

X:  
deletefiles.bat

回答by jeroen

Try Shift+ Delete. Did 24.000 files in 2 minutes for me.

试试Shift+ Delete。在 2 分钟内为我完成了 24.000 个文件。