Batch 批处理搜索文件

来源:互联网 发布:激战2人女捏脸数据 编辑:程序博客网 时间:2024/06/05 08:27

试试搜索文件

粗糙的写了个

感觉写bat爱写成c的格式。。不知道这样写会不会降低效率(囧,Orz

先判断是否存在硬盘,然后在搜索文件


@echo offsetlocal EnableDelayedExpansion:beginset "disk=a b c d e f g h i j k l m n o p q r s t u v w x y z"set FilePath=set /p FileName=请输入文件名:for %%i in (%disk%) do (set DiskName=%%i:if exist !DiskName! echo 正在%%i盘查找:& call :find !DiskName! FilePathif defined FilePath echo 找到文件:!FilePath! & goto :end):endif not defined FilePath goto :notfound404set /p "=按任意键退出" < nul pause > nulgoto :eof:findfor /f %%i in ('dir /b/s %1"\%FileName%"') do (set %2=%%i & goto :eof)goto :eof :notfound404echo 没有找到set /p "=按任意键退出" < nulpause > nul


原创粉丝点击