如果存在,请批量检查是否区分大小写 [英] if exist check with case sensitive in batch
本文介绍了如果存在,请批量检查是否区分大小写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要检查给定文件是否存在,并区分大小写,在我运行脚本的位置中存在out.txt(均为小写字母)文件.
I need to check whether the given file is exist or not with case sensitive, out.txt(all are small letters) file is present in location where i running the script.
代码:
Case1:
filename=out.txt
if exist %filename% (
echo file exist...
) else echo File doesn't exist...
Case2:
filename=OUT.TXT
if exist %filename% (
echo file exist...
) else echo File doesn't exist...
对于这两种情况,它都显示文件存在...输出.但是我需要检查是否区分大小写.它应该显示OUT.TXT的文件不存在"消息.
For both case it showing file exist... output. But i need to check with case sensitive. It should show "File doesn't exist" msg for OUT.TXT
预先感谢
推荐答案
从参数中获取文件名:
@echo off
dir /b /a-d "%~1"|find "%~1" >nul
if %errorlevel% == 0 (echo found) else (echo fail)
dir
实际上不区分大小写-但是find
是...
dir
is in fact not case sensitive - but find
is...
这篇关于如果存在,请批量检查是否区分大小写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文