>nul for DEL

  • Thread starter Thread starter Norbert Winkler
  • Start date Start date
N

Norbert Winkler

Hi,

in a .bat I've the following statements:
ATTRIB -h ~*.* /s >NUL
DEL ~*.* /s >NUL

but DEL reports "\~*.* konnte nicht gefunden werden"
with and without >NUL
ATTRIB is silent with >NUL.
 
Norbert Winkler said:
Hi,

in a .bat I've the following statements:
ATTRIB -h ~*.* /s >NUL
DEL ~*.* /s >NUL

but DEL reports "\~*.* konnte nicht gefunden werden"
with and without >NUL
ATTRIB is silent with >NUL.

You are currently redirecting "Standard Output" to nul. To suppress error
messages, you must redirect the "Error Output":

del ~*.* /s /q 1>nul 2>nul

The /q switch is optional. Run del /? to see what it means.
 
Norbert said:
DEL ~*.* /s >NUL

but DEL reports "\~*.* konnte nicht gefunden werden"
\__________________________/
|
could not be found

Note: When translating your post to English, do the same for the error
messages you note in your post.


Can you guarantee that none of the tilde-prefaced files include spaces
in their names? If not, use "~*.*" (i.e., enclose the filespec with
double quotes) to ensure the string is delimited to include proper
parsing in case there are spaces in the filename(s). Trying to delete
'multi part name.ext' results in trying to delete files named 'multi',
'part', and 'name.ext'. The DEL command can take multiple files as
arguments so if some have spaces then you need to ensure you are
delimiting them to include their spaces. Use:

del "~*.*" /s >nul
 
VanguardLH said:
\__________________________/
|
could not be found

Note: When translating your post to English, do the same for the error
messages you note in your post.


Can you guarantee that none of the tilde-prefaced files include spaces
in their names? If not, use "~*.*" (i.e., enclose the filespec with
double quotes) to ensure the string is delimited to include proper
parsing in case there are spaces in the filename(s). Trying to delete
'multi part name.ext' results in trying to delete files named 'multi',
'part', and 'name.ext'. The DEL command can take multiple files as
arguments so if some have spaces then you need to ensure you are
delimiting them to include their spaces. Use:

del "~*.*" /s >nul

While what you write is entirely correct, the command you suggest will not
suppress the error message that the OP wishes to suppress. At least this is
what I think he wishes to achieve.
 
Pegasus said:
While what you write is entirely correct, the command you suggest will not
suppress the error message that the OP wishes to suppress. At least this is
what I think he wishes to achieve.

Except *if* the error is getting caused by trying to delete a file that
doesn't exist because of the parsing at space characters then delimiting
the string with double-quotes gets rid of the error message. Rather
than trying to mask out the error messages, instead eliminate them from
happening in the first place. After all, the OP might think the command
worked but the files remain because the command did NOT execute against
the correct filename.

If the problem is deleting "~this has mult parts.ext" then that file
won't be found if the double-quotes are missing or worse yet the WRONG
files get deleted. The delete command will try to delete 4 files
instead of the one the OP was trying to target. If those files don't
exist, an error happens. If they do exist, the OP just deleted the
wrong files (4 of them instead of just 1).

If the error doesn't occur, there's no need to mask it out.
 
Back
Top