@echo off>output.txt & setlocal enabledelayedexpansion set input=input.txt rem this finds the text INTERPOLATED HYDROGRAPH in the input file rem sets k0 = to that line# rem sets x = to that line# + 6 and rem sets y = to that line# + 8 for /f "tokens=1,5 delims=[] " %%a in ('find /n "INTERPOLATED HYDROGRAPH"^<%input%') do ( set /a x=%%a+6 set k0=%%b echo line !x! set /a y=%%a+8 call :xx ) goto :eof :xx rem this line takes the line #s and extracts the following: rem 2nd column of line !x! and the 6th columns of line !y! rem find /n /v ""<%input%|findstr "^\[!x!\]" for /f "tokens=2 delims= " %%a in ('find /n /v ""^<%input%^|findstr "^\[!x!\] "') do set k=%%a for /f "tokens=6 delims= " %%a in ('find /n /v ""^<%input%^|findstr "^\[!y!\] "') do set k2=%%a rem this writes the values to a text file >>output.txt echo %k0% %k% %k2%