我正在尝试像在文件夹中一样批量搜索文件,并且可以键入要查找的内容,它将显示该文件中带有该字符串的文件名,但是我想将其用作变量一批
喜欢金达
@echo off
:Start
Title Details Search
set /P "result1=Number1"
for /f %%i in ('findstr /i "%result%" "C:\Users\%USERNAME%\Desktop\Folder\*"') do @echo %result1% found in %%~nxi
set /P "result2=Number2: "
for /f %%i in ('findstr /i "%result2%" "C:\Users\%USERNAME%\Desktop\Folder\*"') do @echo %result2% found in %%~nxi
Pause
它不能允许我做很多事情,其中下面一个可以很好地工作,尤其要感谢格哈德·巴纳德,但只有它一个
@echo off
:Start
Title Details Search
set /P "result=what would you want to search today?: "
for /f %%i in ('findstr /i "%result%" "C:\Users\%USERNAME%\Desktop\Folder\*"') do @echo %result% found in %%~nxi
Pause
我试图获得的结果类似于
鲍勃543-434-4324 汤姆234-253-2463
名称是文件名,数字是我键入的名称。因此,如果我输入数字,它将显示在找到的文件名旁边 注意-这些不是实数,我只是输入随机数
答案 0 :(得分:0)
因此,根据您有问题的更改,搜索多个数字。您需要在搜索中添加由空格分隔的文本。即09122 123441 881992
@echo off
:Start
Title Details Search
set /P "result=what would you want to search today?: "
for %%a in (%result%) do (
for /f %%i in ('findstr /i "%%a" "C:\Users\%USERNAME%\Desktop\Folder\*.rtf"') do @echo %%~nxi %%a
)