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.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Redirect the output of the
delcommand to nul. Note the2, to indicate error output should be redirected. See also this question, and especially the tech doc Using command redirection operators.Or you can check for file existence before calling
del:Note that you can use
if exist c:\folder\(with the trailing\) to check ifc:\folderis indeed a folder and not a file.