By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

How to? Suppress "File Not Found" in a batch file

My batch file is one line:

dir *.$?? /4/p/h/k/m

It correctly reports only the filenames if any with the extension .$?? exist

I simply want to suppress the "file not found" message if no such files exist.

(I actually use 4DOS.)

Many thanks!
One way would be to just not call DIR unless some matching files exist:
if exist *.$?? dir *.$?? /4/p/h/k/m

Another way, if you just want to hide error messages, would be to redirect stderr to the bit bucket:
dir *.$?? /4/p/h/k/m >&> nul:

Similar threads