I use the command
del "info*"
to delete a group of files starting with "info". The problem is that sometimes there is at least one of these files that exist,therefore they are deleted and others times no files exist and and error message happens. I need my script must not block if these files don't exist.
I look at options for del /? but nothing help me go ahead.
Could you help me, please?
Use double percent signs ( %% ) to carry out the for command within a batch file. Variables are case sensitive, and they must be represented with an alphabetical value such as %a, %b, or %c. Required. Specifies one or more files, directories, or text strings, or a range of values on which to run the command.
Force delete using WindowsWith the command prompt open, enter del /f filename , where filename is the name of the file or files (you can specify multiple files using commas) you want to delete.
Did you tried something like this :
IF EXIST [Filename] ( del [Filename] ) ELSE ( ... )
try this:
del "file to delete" >nul 2>&1 del "info*" >nul 2>&1
This sends normal and error messages to nul
.
del "file to delete" 2>nul del "info*" 2>nul
This sends only error messages to nul
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With