suppressing "file not found" on Dir Command

T

TJT

In Windows 2000, I am issuing a Dir command and I am directing the output to
a file, for example
dir xxx*.txt > c:\DirOutput.txt

In the case where there are no files found with the mask specified, I get a
message showing up in the CMD window "File not found".

It is expected that in some instances that there will be no files and of
course to the user, it looks like there is some kind of error. Is there
anyway to suppress this message?

Thanks in advance.
 
G

Guest

If you do not want the "File not found" message in your output file either,
use:

dir xxx*.txt > c:\DirOutput.txt 2>nul
 
F

foxidrive

dir xxx*.txt > c:\DirOutput.txt 2>&1

Austin M. Horst

This will suppress it, by redirecting Standard Error (STDERR) to the NUL
device.

dir xxx*.txt > c:\DirOutput.txt 2>nul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

suppressing dir output 14
dir without path? 5
another FOR question 4
Batch file path 4
DIR and Arrays 4
Dir command help? /s attribute keeps seaching full drive? 26
dir > LPT1 5
fname = Dir("C:\Bob\*.*") 1

Top