TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Fastest Way to Delete Large Folders in Windows (2015)

109 pointsby megahzalmost 8 years ago

26 comments

makecheckalmost 8 years ago
Unless you are extraordinarily low on disk space, you should never need to &quot;wait&quot; to delete things so speed shouldn&#x27;t matter.<p>The correct method is to immediately move&#x2F;rename the target, then launch an expensive delete in the background. That frees up the location you are trying to use.<p>I used to see people set up entire workflows that started with, essentially, &quot;wait 20 minutes to finish recursively deleting the previous data&quot; instead of just &quot;move it out of the way and start immediately&quot;.
评论 #14797503 未加载
评论 #14797582 未加载
评论 #14797115 未加载
captainmuonalmost 8 years ago
Wasn&#x27;t at some distant time in the past deleting done by just renaming a file and changing the first character to a question mark? I think that also applied to folders: Delete a folder&#x27;s &quot;file&quot;, and all the contents are gone, recursively. Not sure how they found free blocks when creating a file though. One downside is that you never knew how much space you had left. I think at some point they changed it so that all file operations updated the &quot;free space left&quot; label in the partition. This may have been FAT around Win98, but maybe I&#x27;m misremembering or it may be some more obscure file system I&#x27;m thinking of...
评论 #14798583 未加载
评论 #14797452 未加载
评论 #14797267 未加载
评论 #14797611 未加载
评论 #14797326 未加载
jongalloway2almost 8 years ago
If you&#x27;re doing this regularly, a good alternative is to install on a separate partition and symlink it. Then to delete, you just quick format the partition.<p><pre><code> echo Y | format Z: &#x2F;FS:NTFS &#x2F;X &#x2F;Q </code></pre> source: <a href="https:&#x2F;&#x2F;superuser.com&#x2F;a&#x2F;352321" rel="nofollow">https:&#x2F;&#x2F;superuser.com&#x2F;a&#x2F;352321</a><p>Also, on Windows 10 you can use Ubuntu bash and run rm -rf. I&#x27;ve read that it&#x27;s faster, but haven&#x27;t tested extensively.<p><i>Update</i>: I did a quick test with 100,000 files and the &#x27;del &#x2F;f&#x2F;s&#x2F;q foldername &gt; nul&#x27; approach was about 50% faster than &#x27;rm -rf&#x27; on my machine.
评论 #14799144 未加载
EvanAndersonalmost 8 years ago
He&#x27;s not handling spaces in directory names in the &quot;cd %1&quot; portion of his context-menu entry. Fortunately his &quot;fastdel.bat&quot; should prompt the user and, hopefully, they&#x27;ll catch the mistake.<p>Calling CMD.EXE from Explorer without double-quoting can have unintended consequences when ampersands and parentheses are present in the filename too. I&#x27;d hate to &quot;Fast Delete&quot; a directory named &quot;&amp; rd &#x2F;s &#x2F;q %SystemRoot% &amp;&quot; using his shell context menu entry.<p>If I was hell-bent on doing this I&#x27;d probably add it to my user registry w&#x2F; the command:<p><pre><code> reg add &quot;HKEY_CURRENT_USER\Software\Classes\Directory\shell\Fast Delete\command&quot; &#x2F;d &quot;cmd &#x2F;c rd &#x2F;s &quot;&quot;%1&quot;&quot;&quot; </code></pre> There&#x27;s still probably some fun metacharacter injection possibilities there, too, however.
bastijnalmost 8 years ago
Unfortunately, RMDIR as well as other windows commands suffer from the long path issue. You can turn on long path name support in win10 but that did break our regular build tooling.<p>My current way to delete any folder regardless depth of the tree is to use robocopy (robocopy D:\EmptyFolder D:\FolderToDelete &#x2F;MIR). It is actually pretty damn fast, might be faster than using RMDIR &#x2F;S &#x2F;Q.
coverbandalmost 8 years ago
This whole page is making me claustrophobic with visions of so many things that can go wrong for trying to optimize the folder delete... Compounded by a helpful samaritan who is offering an EXE download to set up a batch file... :(
moominalmost 8 years ago
The answer to this used to be Visual SourceSafe.
评论 #14797088 未加载
评论 #14797346 未加载
评论 #14799333 未加载
ramshankeralmost 8 years ago
At some point&#x2F;scale, quick format would be even faster.
laurent123456almost 8 years ago
Reading this article reminds me how tedious it is to customise Windows. All these manual steps in system dialogs, registry and so on have to be repeated every time you want to re-install Windows.<p>I wanted to run a command as admin on startup recently and had to create a scheduled task for this, which of course will be lost the next time I reinstall. Same for services, etc.
评论 #14798774 未加载
Filligreealmost 8 years ago
I haven&#x27;t used Windows seriously for a while, but I&#x27;m pretty sure you can use filenames without extensions now.<p>Doesn&#x27;t that mean that the &quot;<i>.</i>&quot; pattern won&#x27;t match everything?
评论 #14797144 未加载
评论 #14798215 未加载
toygalmost 8 years ago
Note that these solutions will bypass the trashcan, which is why they shouldn&#x27;t really be used willy-nilly.<p>They will also trip up in the same way Explorer does, on paths that are too long.
评论 #14797253 未加载
coinalmost 8 years ago
Summary - use command line tools
krylonalmost 8 years ago
Does anyone know how PowerShell compares to cmd.exe for this particular problem? In PowerShell, one would type:<p><pre><code> rm -Recurse -Force $path </code></pre> It has the advantage that it only takes a single command, but I am not entirely certain about the performance.
评论 #14797433 未加载
评论 #14797814 未加载
hardlianotionalmost 8 years ago
Similar issue deleting files through OS X Finder, also solved by going to the command line.
vorotatoalmost 8 years ago
Okay but presumably it&#x27;s doing something with that extra time, is it valuable?
评论 #14797308 未加载
test6554almost 8 years ago
Now if we could only delete files that are allegedly in use by another process.
评论 #14799023 未加载
agumonkeyalmost 8 years ago
Never reached a case where shift + del wasn&#x27;t fast enough, interesting
评论 #14807380 未加载
damien207almost 8 years ago
I will suggest to try &quot;Long Path Tool&quot; program.
tsomctlalmost 8 years ago
On a related note, Cygwin is also faster that Windows Explorer, although I don&#x27;t know how it compares to RMDIR.
winstonewertalmost 8 years ago
Is there actually a reason to do both del and rmdir instead of just rmdir? Or is the post just being superstitious?
评论 #14797089 未加载
frederik0203almost 8 years ago
Try using long path tool . It worked for me. I hope it helps.
LinuXYalmost 8 years ago
<a href="https:&#x2F;&#x2F;windirstat.net&#x2F;" rel="nofollow">https:&#x2F;&#x2F;windirstat.net&#x2F;</a>
评论 #14797492 未加载
评论 #14797430 未加载
nvivoalmost 8 years ago
rimraf is extremely fast. Started using it to delete large node_modules folders and got used to it.
评论 #14798256 未加载
jscholesalmost 8 years ago
Legitimate question - why&#x2F;how has this made it to the front page?
评论 #14797143 未加载
评论 #14797334 未加载
评论 #14801636 未加载
coding123almost 8 years ago
Install Linux?
xorialmost 8 years ago
Can&#x27;t you just SHIFT+DELETE?
评论 #14797073 未加载