Suppress error messages in Windows commandline

batch-file, shell, windows

Solution

Redirect the output to `nul`

mkdir "C:\users\charqus\desktop\MyFolder" > nul

Depending on the command, you may also need to redirect errors too:

mkdir "C:\users\charqus\desktop\MyFolder" > nul 2> nul

Microsoft describes the options here, which is useful reading.

Problem

Let's say I already have a folder created on the next path file: `"C:\users\charqus\desktop\MyFolder"`, and I run the next command on CMD: ``` mkdir "C:\users\charqus\desktop\MyFolder" ``` I get a message like this: "A subdirectory or file C:\users\charqus\desktop\MyFolder already exists". Therefore, is there any command in the commandline to get rid of this returned messages? I tried echo off but this is not what I looking for.

Original source