Monday 31 December 2018

windows 7 - How can I delete over 2,000,000 files in a single directory efficiently?


I have over 2,000,000 (that's right, over 2 million) files in 'Temporary Internet Files'.


This predicament is the result of a scheduled task that runs a script. After installing Visual Studio, it has been generating numerous 'Assembly Binder Log Entry' .HTM files each time it runs.


It's been doing this every 15 minutes for 8 months. So now there's over 2,000,000 and 8 GB worth of these files in there (no wonder WinDirStat and Everything have been crashing!).




How can I delete a folder without iterating over all 2,000,000 of its contents?


I tried opening the parent folder in Explorer and simply pushing the Del key. Windows then proceeded to attempt sending 2,000,000 files to the Recycle Bin (nope). It never got past the 'Discovering Items' phase.


I went for PowerShell next (Remove-Item 'Content.IE5'), but it's attempting to recurse through each file and delete them individually. While this seems like it will work eventually, I feel like there must be a better way.


Bonus points if you can tell me what the heck Assembly Binder Log Entry files are...



Answer



According to a similar question from StackOverflow there are a couple things you can do. Quoting from the highest rated answer (not the accepted) the best method of doing such as task is:



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:



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

Obviously you will need to adapt this answer to suite your specific purposes since you are deleting a series of files rather than a folder.


This user suggests (and I would agree) the worst way to achieve such a task would be select all and Del with next worst being select all Shift+Del


Afraid I have no idea what the log entry file is.


Source - stackoverflow


No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...