Jos*_*hua 5 windows batch-file cmd.exe
这更像是一个好奇问题,但是 Windows Batch 中有没有一种方法可以创建if file.ext exists && if file2.ext exists (echo Yes.) else (echo No.)
-type 命令?
是的,您可以实现 AND/OR 运算符,例如:
if exist file1.ext (
if exist file2.ext (
echo Yes, both file1.ext and file2.ext exist
) else (
echo No, both file1.ext and file2.ext not exist
)
) else (
If exist file2.ext (
echo file1.ext does NOT exist but file2.ext does exist
)
)
Run Code Online (Sandbox Code Playgroud)
要检查 File2.ext 是否存在且 file1.ext 不存在,请执行以下操作:
if exist file1.ext (
if not exist file2.ext (
echo file1.ext does exist but file2.ext does NOT exist
)
)
Run Code Online (Sandbox Code Playgroud)
Else 关键字的放置很重要!
阅读更多:
归档时间: |
|
查看次数: |
14384 次 |
最近记录: |