![](/img/trans.png)
[英]Why does echo not print the text within an if statement (windows batch file)?
[英]batch - Why does successful dir statement print File Not Found?
最近,我制作了一个小的批处理文件以列出给定目录中的所有文件。 当我运行该文件时,它会成功生成所有文件的txt。 但是,如果我从命令提示符下运行它,它还会打印File Not Found
。
dir ".\builds\dev-versions" /b /o:d *.jar > devFiles.txt
是什么导致这种情况发生?
您的dir
命令应该运行两次-每个参数".\\builds\\dev-versions"
和*.jar
.
表示“当前目录”,因此它应同时列出指定目录和当前目录中的所有.jar
文件。 如果任一列表为空,则将得到file nor found
错误。
由于您没有告诉我们代码正在尝试执行的操作,因此我们只能提出补救措施。 追加2>nul
可以通过丢弃错误报告来提供帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.