Delete a directory and its files using the command line, but do not run an error if it does not exist


I need a Windows command to delete a directory and all its containing files but I do not want to see any errors if the directory does not exist.

Redirect the output of the del command to nul:

del {whateveroptions} 2>nul

Or you can check for file existence before calling del:

if exist c:\folder\file del c:\folder\file

Note that you can use if exist c:\folder\nul or just if exist c:\folder\ (with the trailing \) to check if c:\folder is indeed a folder and not a file.