Delete a directory and its files using command line but don’t throw error if it doesn’t exist

Redirect the output of the del command to nul. Note the 2, to indicate error output should be redirected. See also this question, and especially the tech doc Using command redirection operators.

del {whateveroptions} 2>null

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\ (with the trailing \) to check if c:\folder is indeed a folder and not a file.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)