试试搜索文件
粗糙的写了个
感觉写bat爱写成c的格式。。不知道这样写会不会降低效率(囧,Orz
先判断是否存在硬盘,然后在搜索文件
@echo off
setlocal EnableDelayedExpansion
:begin
set "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! FilePath
if defined FilePath echo 找到文件:!FilePath! & goto :end
)
:end
if not defined FilePath goto :notfound404
set /p "=按任意键退出" < nul
pause > nul
goto :eof
:find
for /f %%i in ('dir /b/s %1"\%FileName%"') do (
set %2=%%i & goto :eof
)
goto :eof
:notfound404
echo 没有找到
set /p "=按任意键退出" < nul
pause > nul