标题: [文件操作] 批处理如何判断多个文件是否存在? [打印本页]
作者: 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
- @echo off&SetLocal EnableDelayEdexpansion&cd /d "%~dp0"
- if exist a.exe set a=1
- if exist b.exe set b=1
- if exist c.exe set c=1
- set /a n=a+b+c
- set /a m=b+c
- if !n! == 3 goto 3
- if !n! == 0 goto 2
- if !a! == 1 if !m! lss 2 goto 1
- pause
复制代码
- @echo off&SetLocal EnableDelayEdexpansion&cd /d "%~dp0"
- if exist a.exe (
- if exist b.exe if exist c.exe goto 3
- goto 1
- ) else (
- if not exist b.exe if not exist c.exe goto 2
- )
- pause
复制代码
作者: yofee 时间: 2012-10-20 08:11
谢谢楼上的朋友半夜帮忙,现在测试OK,还有楼上的朋友不要太晚睡了
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |