Normally, to delete a small amount of data in Windows, you can just either hit Delete key to send them to the Recycle Bin or Shift + Delete to permanently delete them right in the File Explorer (Windows Explorer) without getting into too much trouble. But both ways can safely be titled the worst way when it comes to cleaning up a large amount of data with a deep folder structure. It wastes so much time checking the contents before starting deleting anything. And it fails a lot more often than usual.
The bottom line, if you are facing a large amount of data to deal with, absolutely avoid using GUI tools like Windows Explorer or File Explorer. In a case like this, command lines work way better.
If you just want to clean up the files but keep the entire folder structure, the following does the job really well.
del /f /s /q foldername
/q is to run the command in quiet mode so no questions asked to delete on global wildcard.
If you want to purge the entire folder including all sub-directories and files, the following can also get you there.
rmdir /s /q foldername
Same as above, it runs in the quiet mode that doesn’t ask if OK to remove a directory tree.
The best way to get the job done the fastest is actually the combination of using both. Run DEL command first to delete all the files and then execute RMDIR to clean up the folder structure. You can also output the DEL command to NIL to avoid the overhead to displays every single file that the command killed.
del /f /s /q foldername > nil rmdir /s /q foldername
You can put both commands in a batch file to finish both jobs in one shot or put the batch job in the scheduler to run them in regularly if needed.
Latest posts by Kent Chen (see all)
- Microsoft To-Do App Available in Preview on Windows 10, iOS and Android - April 19, 2017
- Windows 10 Tip: What’s Mini View in Movies & TV App and How To Use it - April 15, 2017
- Windows 10 Tip: How To Convert MBR Partition to GPT without Losing Data - April 12, 2017
Last updated: 02/21/2016