Removing folders with a large quantity of files can take up quite some time. Windows explorer first calculates the the removal time by counting the files and sizes before the removal process eventually starts.
There are faster ways to remove these large folder by batch and PowerShell. Both don’t do any form of calculation, but begin the deletion immediately.
With batch, we need to perform two actions. The first one is DEL
to delete all the files in folders and subfolders. The second action is RMDIR
to remove the empty folders and subfolders. The output of the file deletion is not send to the terminal by using > NUL
. This reduces the deletion time by a fair amount.
@ECHO OFF SET FOLDER="C:\Large Folder" CD / DEL /F/Q/S "%FOLDER%" > NUL RMDIR /Q/S "%FOLDER%" MD "%FOLDER%" exit
We can perform the same action with PowerShell in a one-liner. In this case we use Out-Nul
l to disable the output. The trigger -Force is used to remove read-only files. -Recurse is used to remove subfolders and subfiles.
Remove-Item "C:\Large Folder" -Force -Recurse | Out-Null
Make sure you entered the folder correctly before you start these scripts. You can cancel the task, but there is no undo button.