A much faster, bare metal approach to deleting large and complex folders in Windows is via the command line. Of course, repeatedly having to navigate directories while executing commands via a terminal quickly becomes a tedious experience. In this post, I will walk through the process of creating a simple batch file and wiring it up to a handy right-click context menu from Windows Explorer to delete sophisticated directories in a hurry and without interruption.
Small tip (from 2015, so I’m a tad late), explained very well, that a lot of people could benefit from.
Powershell exists and is much more useful, if a bit wordy.
https://technet.microsoft.com/en-us/library/ee176938.aspx
Also, careful with the script on the linked page, I copied a more sophisticated version of that back in 1990 or so, but completly screwed up and ended up nuking the DOS folder giving me the dreaded “bad or missing command interpreter” on next boot.
A batch file is not DOS
A command prompt is not DOS
Powershell is not DOS
Just because you see a terminal or something you don’t recognize as Windows doesn’t mean it is another OS.
As for the question “why the command prompt, not powershell?”
* The command prompt starts much faster
* PowerShell is present by default only on recent Windows versions
And for the reverse question:
* PowerShell is much better at using the output of 1 command as the input for another because it is object based and not text based
* PowerShell is much better at handling errors internally and displaying them colorcoded
No, those are commands that date back to DOS 2/3, they are DOS commands. Likewise Batch files date back to the DOS era. The suggestions will probably work with FreeDOS today and likely work back to DOS 3 at least.
PowerShell is installed by default since Windows 7. The oldest supported version of windows is… Windows 7. I don’t think its a bad general suggestion, in light of that.
Is powershell really slower to start up? On my three year old laptop, I can’t tell the difference.
Trust me I lived and breathed DOS commands and batch files. I know the pitfalls they contain, I would never suggest that anyone write another batch file they didn’t absolutely have to.
Sure, those commands were DOS commands, but the topic here is “Windows does things slowly, here is how you can speed it up”. The solution has nothing to do with DOS.
PowerShell is included by default since Windows 7 / Server 2008 R2. But it isn’t always available (deactivated, PE-environments). So whenever you want to do something FAST, you should use cmd.exe, not powershell.exe. If you want to do something user-friendly or complicated PowerShell is absolutely a better option.
CMD starts about 10 times as fast as PowerShell, but we are talking about 0.1 vs 1 second here. Still enough reason for me to revert back to “DON’T Replace Command Prompt with Windows PowerShell in the menu when I right-click the start button or press Windows key+X” since the 1703 Update
I am still living and breathing DOS commands, batch files, PowerShell, etc. They are incredibly useful and I couldn’t do most of my work well without them.
Dos commands: For when you want to do something once or twice quickly
Batch files (*.cmd): For when you have several related tasks that you execute many times
PowerShell: For when you have real scripting needs, especially to manage Microsoft Server Programs. But almost never for a quick one-liner
SHIFT+Del (it omits wastebin and it’s fast)
However, delete files (directories) by moving every file one by one to the wastebin is not so smart… what about it Microsoft?
Not fast enough, it’s usually faster just to boot into windows pe or recovery console, it can save 10+ minutes sometimes. Just press shift+f10 to bring up a console.
Usually faster? Only if you are going to perform 1 very longrunning task like imaging/restoring an OS.
Closing all your open programs, rebooting into PE, rebooting back into regular Windows, that takes a lot longer than most tasks would and you have a much more limited environment at your disposal.
The great thing about running in PE is that your are running without any virusscanner, indexing services and are running as “SYSTEM”, but the use cases for this are rare and almost all related to largescale system maintenance
It’s not 1995, no one uses “Recycle Bin” any more. Your comment isn’t even related to the article.
Also, the “Recycle Bin” feature was implemented to allow careless users to restore files they delete “accidentally”, which would happen quite often. And it was kinda smart in that regard.
People still use the Recycle Bin in 2017 because they are still careless users that need to restore files they delete accidentally. This idea has been implemented in many products internally as well, from a “simple” Undo/Redo to actual recycle bins in mail programs, and multilevel (user/admin) recycle bins in tools like SharePoint, Exchange and OneDrive just to name a few
lol, Windows really does the equivalent of find | ls -lh before it deletes anything? What a piece of shit excuse for an OS.
I mean, if you want any sort of feedback during the delete process – total files, amount of disk space recovered, etc, then, yeah, it has to gather that information ahead of time.
Otherwise, you’ve just got a plain window saying “Deleting files…” in it.
Which, in turn, would cause people – probably you included – to post something along the lines of “lol, Windows really can’t tell me any information about what I’m deleting? What a piece of shit excuse for an OS.”
And, technically, it is Explorer that does this, as obviously using del is much faster.
> Which, in turn, would cause people – probably you included – to post something along the lines of “lol, Windows really can’t tell me any information about what I’m deleting? What a piece of shit excuse for an OS.”
No, my usual method of deleting files is “rm”. I’m fine with zero output.
And most of us aren’t. Just because an OS is catering to different set of needs than your own, does not mean it’s “shitie”.
And you represent the world? Quite a bit of ego there.
It isn’t an optimal solution though that doesn’t really represent the OS design – this is about the graphical shell. A better solution would be starting a new thread for doing the UI stuff while deleting things in the original thead. In this way the original thread is decoupled and needn’t wait for the UI one to do any work. If the deletion is finished before the UI thread have opened up a window then simply kill it, otherwise asynchronously update the statistics.
Not that you’ll ever understand this.
I’ve never met one person in twenty years of dealing with tech that wanted the progress popups. It’s always been just another thing to ignore.
And I’ve met ONLY people who DO want progress bars. You see, again, your world is very, very limited and you should not assume everyone has same needs and experience as you and your friend circle.
It doesn’t do that entirely before anymore. (That was the main reason Vista had such horrible file-management-issues)
It does it mostly during, just like most other userfriendly filemanagers do (Total Commander comes to mind) for reasons already described. It is a very nice compromise between speed and usability that you can avoid if you really need speed in edgecases like they are described here
Please stop trolling alternatively take your medication.
format c: /q /x
Did you at any point think your comment will sound even remotely funny or smart?.. Or are you just a happy 14-year old who recently learned few things about computers?
Running as a non-elevated local admin:
Access Denied as you do not have sufficient privileges.
You have to invoke this utility running in elevated mode.
Cannot open volume for direct access.
Running with elevation:
The type of the file system is NTFS.
Enter current volume label for drive C:
(have to look up the volume label in another window, type it)
WARNING, ALL DATA ON NON-REMOVABLE DISK
DRIVE C: WILL BE LOST!
Proceed with Format (Y/N)?
(still trying to get your nonsense to work, so choosing Y)
QuickFormatting 128,0 GB
Cannot lock the drive. The volume is still in use.
Format failed.
s3cr3to is confirmed to be a complete NOOB that doesn’t understand the difference between a folder and a volume and that doesn’t understand the difference between DOS and Windows
Its kinda retro joke. Not bad. Basically, He’s saying 640k should be enough for everybody.
It stands alone without a literal interpretation of the joke with a reply stating the truth that all computers for the last 30 years have had more than 640k for reasons.
Unless the reply itself was a subtle meta joke, in which case, well played.
That joke is so played out and irrelevant that it is no longer funny in any way and can no longer be considered a joke.
Of course it is, that’s what makes it funny.
Its the “How Do You Do, Fellow Kids?” of its day.
I’m not sure you know what “funny” means.
I have no doubt that most people do not understand what makes good comedy or music. But, I am not one of those.
Having to constantly assure people that you have a sense of humour is not exactly a trait of a person who understands comedy.
Edited 2017-07-20 16:30 UTC
Eh, I’m not assuring people in the above comment, just making a remark that I understand I’m in the minority here. I don’t really care what other people think, so much as I’m trying to bridge the gap between lonely souls in this crazy topsy turvy world in which we live in.
You are either getting too philosophical for a tech. site, or you’re just drunk. Either way, I don’t really care to try to understand potentially “deep underlying meaning” of your comments.
If anyone mentions the 640k shit it is a clear warning that they are basically clueless about anything. Ditto the format comment.
Not funny. Not relevant. Not meta-funny nor meta-relevant. No factual basis, no historical weird thing etc. Nil gives more and is more relevant.
Well, that’s just my opinion. But I’m always right.
Well, yes. That or they want you to lure you into a false sense of superiority, playing a long con setting your up for a humbling fall
Should really look into these two tools:
Total Commander: http://www.ghisler.com/
Everything: https://www.voidtools.com/
These two can even integrate so you can perform a search on multiple drives on any criteria that you can think of (even inside file contents, filesize or age) and because of the way Everything works that search usually just takes a second. The output of that search can then be used for further processing like deleting
Totalcommander is a big buggy when copying/deleting a large quantity of files and folders as it progressively slow down as the process progress. It’s like it stores the list of files/folders and visit it from the beginning for every entry. At the beginning it is fast, but after like 30k entries, it goes rather slow. Stop the process, restart it and it goes fast again. Repeat it several time or on smaller batches and you get the job done faster than if you let the initial job finish in one go.
Total Commander isn’t buggy, but it is taking care of some things that Explorer doesn’t, for example Comments. You can configure this to some extend in Configuration -> Options -> Operation -> Copy/Delete.
Total Commander is also not optimized for speed but for control. So just “F2” such long running processes to the background
Reading the comments in this article it’s clear I’ve fallen through a wormhole back to the mid-90’s. Phew! This is a great opportunity for me to buy APPL stock (just trust me on this!) and sell of my Amiga hardware while the going is still good.
Almost all of these tips apply to macOS in some form or another. There is a whole spectrum from “Perform an action as quick as possible” and “perform an action as failsafe as possible” and although the details change between OS-ses and filesystems the general idea is the same
Using CMD instead of explorer will eliminate a pile of overhead, since it doesn’t need to check whether files are deletable and rename them. There are other things to go further though:
1. Disable short file names. With short file names enabled, every long file name ends up with two entries in the directory index, and delete has to remove both. See “fsutil 8dot3name”.
2. Disable the tunnel cache. This beast will monitor deletions of files and record the long/short name pair in a data structure so that if the short name is created in future the long name is resurrected. You probably don’t ever want this anymore. Create a REG_DWORD value in HKLM\System\CurrentControlSet\Control\FileSystem called MaximumTunnelEntries and set it to zero.
3. Turn off USN. This is a log that records changes to a volume for indexing, replication and the like, so every delete ends up writing a log record indicating it happened. It’s required on the system volume, but if you have data going to another volume and you don’t need it, turn it off – see “fsutil usn deletejournal”.
4. Check what filters you have and think about whether you need them. These are plugins that monitor file system operations and may take actions in response. It’s hard to generalize about the cost of filters, since each one has its own behavior; some are cheap, others less so. Check what you have with “fltmc”.
5. Finally, notwithstanding the confusion in the comments, if you can move all of the data you intend to delete to its own volume, formatting that volume will be faster than deleting the files. Format just lays down new file system structures; delete needs to visit each file in turn. So if you have something like a build system that generates large numbers of outputs that you know you want to delete, send them to a different drive, and format it when you’re done. Note that you could even have this “drive” be a VHD if that makes sense in a given environment.
Needs upvoting!
I have installed and tested a program called “Fast folder erase free”, it links to explorere so that a right click on the the folder brings up the option to erase the folder.
When I downloaded it, it was free of viruses/malware but you need to check it yourself as always when you download it. No more wasting time while it explores the folder and fails to ever start deleting.
I also use fastcopy to avoid the same when performing a copy operation.
Windows NT6+ introduced this appalling behaviour and it has annoyed me ever since. Viva XP!
Thanks for the informative post & for providing us with this great write up, Keep it up.
Do Visit Adaaloâ„¢