Board logo

标题: [文件操作] 批处理如何判断多个文件是否存在? [打印本页]

作者: yofee    时间: 2012-10-20 00:02     标题: 批处理如何判断多个文件是否存在?

文件中有多个文件其中包含a.exe和b.exe和c.exe等,批处理判断:如果a.exe存在,但b.exe和c.exe同时不存在,或其中一个不存在时就goto 1 ,如果3个文件都不存在就goto 2,如果3个文件都存在就goto 3
作者: wc726842270    时间: 2012-10-20 04:10

我想你的描述好像少了些什么。
我猜,不存在权限和文件属性的问题,那么是否是全盘查找,还是单个文件夹,或是一个子目录呢?
作者: QIAOXINGXING    时间: 2012-10-20 04:13

  1. @echo off&SetLocal EnableDelayEdexpansion&cd /d "%~dp0"
  2. if exist a.exe set a=1
  3. if exist b.exe set b=1
  4. if exist c.exe set c=1
  5. set /a n=a+b+c
  6. set /a m=b+c
  7. if !n! == 3 goto 3
  8. if !n! == 0 goto 2
  9. if !a! == 1 if !m! lss 2 goto 1
  10. pause
复制代码
  1. @echo off&SetLocal EnableDelayEdexpansion&cd /d "%~dp0"
  2. if exist a.exe (
  3.   if exist b.exe if exist c.exe goto 3
  4.   goto 1
  5. ) else (
  6.   if not exist b.exe if not exist c.exe goto 2
  7. )
  8. pause
复制代码

作者: yofee    时间: 2012-10-20 08:11

谢谢楼上的朋友半夜帮忙,现在测试OK,还有楼上的朋友不要太晚睡了




欢迎光临 批处理之家 (http://www.bathome.net/) Powered by Discuz! 7.2