Batch Programming turn off messages

I am writing a batch file routine.  I need to create a file structure and I am using the md command to accomplish this.

md c:\NetworkDsgn\CoaxMaps\DWF\OH

My Question is the second time I run this application I get the following message.  

A subdirectory or file c:\NetworkDsgn\CoaxMaps\DWF\OH already exists.

Is there a way to turn this message off?  The application runs fine it is just a nuisance message that I would like to not show.  PS. I need to show other messages and I am using the ECHO command to do so.

Thanks,
Bob


Bob StammOperations ManagerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Harisha M GEngineerCommented:
Use

md c:\NetworkDsgn\CoaxMaps\DWF\OH 2> NUL
mgalig1010Commented:
Hi RobertStamm,
Try
 md c:\NetworkDsgn\CoaxMaps\DWF\OH > Null


Regards,
Marcos
Harisha M GEngineerCommented:
RobertStamm and mgalig1010, to redirect error message, you should use 2>
CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Rob_JeffreyIT/ProgrammingCommented:
Under XP you can't redirect errors by re-routing output to NULL so I use an if statement:

@echo off

IF exist C:\temp goto END

md \temp

:END


Bob StammOperations ManagerAuthor Commented:
mgh mqharish,
Thank you.  just what I needed.
Bob
Harisha M GEngineerCommented:
>> Under XP you can't redirect errors by re-routing output to NULL

Really ? Test NUL instead of NULL :)

Thanks Bob.
InteractiveMindCommented:
>> Under XP you can't redirect errors by re-routing output to NULL

Wrong.

   md c:\NetworkDsgn\CoaxMaps\DWF\OH >Nul 2>&1

'>Nul 2>&1' will diminish even output to the error stream.
Harisha M GEngineerCommented:
IM, what's &1 ?
Rob_JeffreyIT/ProgrammingCommented:
Seen.
-->It redirects file handle 2 to file handle 1.  File handle 1 was redirected to
-->nul (> nul), so it is also redirecting file handle 2 (stderr) to nul.
-->This is the syntax to use if you want no normal output and no error output for
-->a console application.


Huh, learned something new.  So... your first answer was incomplete :)

InteractiveMindCommented:
Cut directly from the XP help page on "Using command redirection operators":


Using command redirection operators
You can use redirection operators to redirect command input and output streams from the default locations to different locations. The input or output stream location is referred to as a handle.

The following table lists operators that you can use to redirect command input and output streams.

Redirection operator Description
> Writes the command output to a file or a device, such as a printer, instead of the Command Prompt window.
< Reads the command input from a file, instead of reading input from the keyboard.
>> Appends the command output to the end of a file without deleting the information that is already in the file.
>& Writes the output from one handle to the input of another handle.
<& Reads the input from one handle and writes it to the output of another handle.
| Reads the output from one command and writes it to the input of another command. Also known as a pipe.  

By default, you send the command input (that is, the STDIN handle) from your keyboard to Cmd.exe, and then Cmd.exe sends the command output (that is, the STDOUT handle) to the Command Prompt window.

The following table lists the available handles.

Handle Numeric equivalent of handle Description
STDIN 0 Keyboard input
STDOUT 1 Output to the Command Prompt window
STDERR 2 Error output to the Command Prompt window
UNDEFINED 3-9 These handles are defined individually by the application and are specific to each tool.

The numbers zero through nine (that is, 0-9) represent the first 10 handles. You can use Cmd.exe to run a program and redirect any of the first 10 handles for the program. To specify which handle you want to use, type the number of the handle before the redirection operator. If you do not define a handle, the default < redirection input operator is zero (0) and the default > redirection output operator is one (1). After you type the < or > operator, you must specify where you want to read or write the data. You can specify a file name or another existing handle.

To specify redirection to existing handles, use the ampersand (&) character followed by the handle number that you want to redirect (that is, &handle#). For example, the following command redirects handle 2 (that is, STDERR) into handle 1 (that is, STDOUT):

1<&2

Duplicating handles
The & redirection operator duplicates output or input from one specified handle to another specified handle. For example, to send dir output to File.txt and send the error output to File.txt, type:

dir>c:\file.txt 2>&1

When you duplicate a handle, you duplicate all characteristics of the original occurrence of the handle. For example, if a handle has write-only access, all duplicates of that handle have write-only access. You cannot duplicate a handle with read-only access into a handle with write-only access.
Rob_JeffreyIT/ProgrammingCommented:
Akin -

md c:\temp >null 2>null

Should work

Since the 1>&1 is actually refering to the first redirect of >nul

Damn cool.
Harisha M GEngineerCommented:
LOL Rob_Jeffrey, he just wanted to remove error messages, not the normal messages ;)
Harisha M GEngineerCommented:
That wouldn't work until you use NUL instead of NULL

Notice single L
Rob_JeffreyIT/ProgrammingCommented:
normal messages?

From  what I understand md c:\temp >nul 2>nul should be exactly the same as md c:\temp >Nul 2>&1


The &1 is referring to the first pipe in the command.

No?
(Sorry for null - Null is Nul)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bob StammOperations ManagerAuthor Commented:
Redistributeing the points due to the additional diccussion following the orginal assigning of points.
Thanks everyone for your input in soulving this issue!
Bob
Rob_JeffreyIT/ProgrammingCommented:
Thank you - but it wasn't necessary.
InteractiveMindCommented:
Appreciated.
Harisha M GEngineerCommented:
Rob_Jeffrey, thanks :)
Harisha M GEngineerCommented:
:))

RobertStamm, thanks for you
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.