我在目录中有两个文件file1.a和file2.a。 我在写一个批处理脚本来查看file1.a是否存在,或者如果file2.a不存在,或者如果booth文件不存在,调用“mycommand”。如果不存在或者如果不存在 - 如何批量处理
我已经试过这样的事情:
if not exist file1.a || if not exist file2.a || if not exist file1.a && file2.a call mycommand
它不工作。任何想法/建议?
我在目录中有两个文件file1.a和file2.a。 我在写一个批处理脚本来查看file1.a是否存在,或者如果file2.a不存在,或者如果booth文件不存在,调用“mycommand”。如果不存在或者如果不存在 - 如何批量处理
我已经试过这样的事情:
if not exist file1.a || if not exist file2.a || if not exist file1.a && file2.a call mycommand
它不工作。任何想法/建议?
你可以扭转你的逻辑和跳过你的命令,如果存在两个文件:
if exist file1.a if exist file2.a goto :SKIP
call mycommand
:SKIP
你被滥用&&
和||
运营商这是命令有条件的分离,这使得第二个取决于执行关于第一个是否成功(例如,copy source destin && echo SUCCESS || echo FAILURE
)。
据我了解,你想跳过如果任一文件的存在,所以我会做这种方式:
if exist file1.a goto skip
if exist file2.a goto skip
goto end
:SKIP
mycommand
:END