Delete files in batch with without error message
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?
Solution 1:
Did you tried something like this :
IF EXIST [Filename] (
del [Filename]
) ELSE (
...
)
Solution 2:
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
.