for /r命令实现全盘搜索指定文件
@echo off Rem :全盘搜索指定文件并输出到文本 set "fileName=Normal.dotm" set "outPutPath=C:\result.txt" echo. > %outPutPath% echo 正在搜索 for %%i in (C D E F G H I J K L M N O P Q R $ T U V W X Y Z) do ( if exist %%i:\ ( pushd %%i:\ for /R %%j in (%fileName%) do ( if /i "%%~nxj" equ "%fileName%" ( echo %%~fj echo %%~fj >> %outPutPath% ) ) popd ) ) echo 搜索完毕,结果已输出到 %outPutPath% pause