The following script, let us call it extract.bat, does what you are asking for. It regards only lines that lie in between the first and second line containing ###################:
@echo off
setlocal EnableExtensions DisableDelayedExpansion
rem // Define constants here:
set "_FRAME=###################"
set "_FILE=%~1" & rem // (use file provided by command line argument)
set "_SEARCH[1]=The signature is timestamped:"
set "_SEARCH[2]=SHA1 hash:"
rem "_SEARCH[...]=...:"
rem // Determine numbers of first and second lines containing string `%_FRAME%`:
set "FRST=" & set "SCND="
for /F "delims=:" %%K in ('
findstr /N /C:"%_FRAME%" "%_FILE%"
') do (
if not defined FRST (
set /A "FRST=%%K"
) else (
if not defined SCND set /A "SCND=%%K"
)
)
rem // Continue only if two lines have been found containing string `%_FRAME%`:
if defined FRST if defined SCND (
rem // Enumerate all search strings `_SEARCH[?]` in alphabetical order:
for /F "tokens=1,* delims==" %%I in ('2^> nul set _SEARCH[') do (
rem // Process currently iterated search string:
for /F "tokens=1,2,* delims=:" %%L in ('
findstr /N /C:"%%J" "%_FILE%"
') do (
rem // Check if current line lies in between the two derived before:
if %%L GTR %FRST% if %%L LSS %SCND% (
rem // Return remaining string value with leading spaces removed:
for /F "tokens=*" %%O in ("%%N") do echo(%%O
)
)
)
)
endlocal
exit /B
Provide your text file as a command line argument, like:
extract.bat "result.txt"
If you want to process the data in between the second and third line containing ###################, change the line...:
for /F "delims=:" %%K in ('
...to:
for /F "skip=1 delims=:" %%K in ('
Increment the skip number accordingly for processing the next block.
If you do not care about the ################### lines (in case your text file does not contain multiple blocks of data), the script can be simplified to this:
@echo off
setlocal EnableExtensions DisableDelayedExpansion
rem // Define constants here:
set "_FILE=%~1" & rem // (use file provided by command line argument)
set "_SEARCH[1]=The signature is timestamped:"
set "_SEARCH[2]=SHA1 hash:"
rem "_SEARCH[...]=...:"
rem // Enumerate all search strings `_SEARCH[?]` in alphabetical order:
for /F "tokens=1,* delims==" %%I in ('2^> nul set _SEARCH[') do (
rem // Process currently iterated search string:
for /F "tokens=1,* delims=:" %%M in ('
findstr /C:"%%J" "%_FILE%"
') do (
rem // Return remaining string value with leading spaces removed:
for /F "tokens=*" %%O in ("%%N") do echo(%%O
)
)
endlocal
exit /B