Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

shell - Suppress error messages in Windows commandline

Let's say I already have a folder created on the next path file: "C:userscharqusdesktopMyFolder", and I run the next command on CMD:

mkdir "C:userscharqusdesktopMyFolder"

I get a message like this: "A subdirectory or file C:userscharqusdesktopMyFolder 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Redirect the output to nul

mkdir "C:userscharqusdesktopMyFolder" > nul

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

mkdir "C:userscharqusdesktopMyFolder" > nul 2> nul

Microsoft describes the options here, which is useful reading.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...