Force Verbose Mode in Windows DEL Command

I sometimes delete masses of files on multiple computers with the Windows command line, with the DEL command, and on some the function is verbose (i.e. outputs the files it deletes as it goes), while on others it's not the case. Is there a way to force the command line utility to always display its progress?

2 Answers

Both the del and erase commands will be silent unless you include the /s argument to delete all files in all subdirectories.

One option is to simply delete the files one by one. Let's say you want to delete everything in the temp folder:

for /f "tokens=*" %A in ('dir /s /b "%TEMP%"') do del /Q "%A"

That will take a while to start up against 2 million files as it will need to list them first and then delete them one by one.

Another option is to use Robocopy and have it mirror an empty directory to delete the files you want. You will get verbose output as each file is deleted. Start with an empty directory (c:\empty) and run something similar to the following:

robocopy c:\empty c:\dir_with_files_to_be_deleted *files_you_want_to_delete.* /mir /v

Or, if you just want to delete all files in a single directory:

robocopy c:\empty c:\dir_to_empty /mir /v

If you're deleting a whole directory, use rd/s/q (rmdir /s /q) instead.

2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like