View Full Version : suppressing "file not found" on Dir Command


TJT
09-05-2006, 02:16 PM
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.

Austin M. Horst
09-05-2006, 02:47 PM
dir xxx*.txt > c:\DirOutput.txt 2>&1

Austin M. Horst

Austin M. Horst
09-05-2006, 02:55 PM
If you do not want the "File not found" message in your output file either,
use:

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

foxidrive
09-05-2006, 02:59 PM
On Tue, 5 Sep 2006 06:47:01 -0700, Austin M. Horst wrote:

> 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

TJT
09-05-2006, 03:51 PM
Thanks! Just what I needed.
"Austin M. Horst" <anonymous@microsoft.com> wrote in message
news:95C80C6F-1CC5-419B-AFCD-8AE47D901305@microsoft.com...
> If you do not want the "File not found" message in your output file
either,
> use:
>
> dir xxx*.txt > c:\DirOutput.txt 2>nul