假设我已经在下一个路径文件上创建了一个文件夹:"C:\users\charqus\desktop\MyFolder"
,然后我在 CMD 上运行下一个命令:
mkdir "C:\users\charqus\desktop\MyFolder"
我收到这样的消息:“子目录或文件 C:\users\charqus\desktop\MyFolder 已经存在”。
因此,命令行中是否有任何命令可以摆脱这些返回的消息? 我试过 echo off 但这不是我要找的。p>
最佳答案
将输出重定向到nul
mkdir "C:\users\charqus\desktop\MyFolder" > nul
根据命令,您可能还需要重定向错误:
mkdir "C:\users\charqus\desktop\MyFolder" > nul 2> nul
Microsoft describes the options here ,这是有用的阅读。
关于windows - 抑制 Windows 命令行中的错误消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20298682/