1、cmd
引用自https://blog.csdn.net/tianxudong2004/article/details/2126853
增加了findstr命令,搜索特定文件名以及文件内容
@echo off& setlocal enabledelayedexpansion
rem +++++++++++++++++++++++++++++++++++++++++++
rem search.bat
rem By xxxx 2022-06-06
rem
rem Version: 1.1
rem +++++++++++++++++++++++++++++++++++++++++++
set stime=%time:~0,2%%time:~3,2%%time:~6,2%
if "%stime:~0,1%"==" " set "stime=0%stime:~1%"
if "%1" equ "" (
echo 命令语法不正确。使用/?查看帮助
goto exit
)
if "%1" equ "/?" (
echo 全盘搜索文件/文件夹或者遍历目录。
echo.
echo SEARCH ^[file^]^[folder^]^[path^] ^[/V^]
echo.
echo ^[file^]^[folder^]^[path^]
echo 指定要列出的文件、文件夹或目录列表。
echo.
echo ^[/V^]
echo 查找相关字符串
goto exit
)
if /i "%1" equ "/v" (
echo 模糊查找
set pwd=%cd%
echo start searching .....
echo.
for %%i in (C:\ D:\ E:\ F:\ G:\ H:\ I:\ J:\ K:\) do (
if exist %%i (
echo ■■■■ Searching for the %%i disk
rem if exist %%i\nul
rem cd /d %%i\ & dir /S/b "%1" 2>nul
cd /d %%i & dir /S/b |findstr "%2$" & echo.
)
)
cd /d !pwd!
echo. &echo. &echo.
) else (
set pwd=%cd%
echo start searching .....
echo.
@rem fsutil fsinfo drives 获得各驱动器盘符
for %%i in (C:\ D:\ E:\ F:\ G:\ H:\ I:\ J:\ K:\) do (
if exist %%i (
echo ■■■■ Searching for the %%i disk
rem if exist %%i\nul
rem cd /d %%i\ & dir /S/b "%1" 2>nul
cd /d %%i & dir /S/b "%1" & echo.
findstr /s /n "%1" %%i* & echo.
)
)
cd /d !pwd!
echo. &echo. &echo.
)
set etime=%time:~0,2%%time:~3,2%%time:~6,2%
if "%etime:~0,1%"==" " set "etime=0%etime:~1%"
echo 开始时间:%stime%
echo 结束时间:%etime%
:exit
2、fzf
https://github.com/junegunn/fzf
优点:搜索速度极快
缺点:只能搜索exe所在路径下的所有文件,需要每个盘符根目录都放置一个exe
语法:
fzf.exe -q password
Q.E.D.