Windows bat脚本:如何判断文件是否存在?
伪代码:
if file exists:
do
xxxx
done
else:
do
xxxx
done
Pseudo code:
if file exists:
do
xxxx
done
else:
do
xxxx
done
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用
exist
:根据“方言”,您可以使用
else
语句。然而,在最底层,一些相当丑陋的逻辑是有效的:You can use
exist
:Depending on the "dialect", you can use
else
statements. At the lowest level, though, some rather ugly logic like this works:语法如下:
IF [NOT] EXIST filename 命令
如果文件不存在(而不是文件存在),您可以使用 [NOT] 选项来执行代码,但这可以作为 ELSE 语句来完成。标准 IF EXIST 语句。
Syntax is as follows:
IF [NOT] EXIST filename command
You can use the [NOT] option to execute code if a file doesn't exist as opposed to if the file does exist, however this can be done as an ELSE staement in a standard IF EXIST statement.