Is it possible to optimize this code?

2

I asked a question here and they sent me a suggestion of a code that does a search on the contents of all .bat files in a directory using as criteria, names that are in a .txt file.

set "File2Read=falhou.txt"
set "File3Read=call.txt"
If Not Exist "%File2Read%" (Goto :Error)
rem This will read a file into an array of variables and populate it 
setlocal EnableExtensions EnableDelayedExpansion
for /f "delims=" %%a in ('Type "%File2Read%"') do (
    set /a count+=1
    set "Line[!count!]=%%a"
)
rem Display array elements
For /L %%f in (1,1,%Count%) do (
    FOR %%G IN (*.bat) do (findstr /m "!Line[%%f]!" "%%G")>>call.txt
)

for /f "delims=" %%a in ('Type "%File3Read%"') do (
    set /a count+=1
    set "Line[!count!]=%%a"
)
rem Display array elements
For /L %%c in (1,1,%Count%) do (
    call "!Line[%%c]!"
)

pause
Exit
::***************************************************
:Error
cls & Color 4C
echo(
echo   The file "%File2Read%" dos not exist !
Pause>nul
exit /b
::***************************************************

The code works, the problem is that it does a very long search, because I have 10 thousand .bat files to be scanned for each of the names, every time a name found the search resumes from the first file.

Would it be possible to improve this in any way?

    
asked by anonymous 27.06.2018 / 15:01

0 answers