Use call only on batch files that contain expressions from another file

1

I have a directory with randomly named .bat files inside every .bat file in this directory I have unique names like:

  • name1
  • name2
  • name3
  • ...

I also have, within the same directory, a just.txt file. In this file, each line is a name of those that are within files with the .bat extension.

I need a command to be executed through a Windows batch file that checks each of the just.txt lines and executes a call in the .bat file that has this name.

Practical example:

abc.bat file code

echo nome10

xyz.bat file code

echo nome1

Text in the only .bat file:

nome1

What needs to be done by the new batch file: call xyz.bat

    
asked by anonymous 26.06.2018 / 01:42

1 answer

1

Try this:

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
::***************************************************

Based on this response link

I have modified as follows, the batch file checks the names inside the file failed.txt , stores the search result in a file call.txt applies the call in files within call.txt.

    
26.06.2018 / 18:02