@echo off&setlocal enabledelayedexpansion
for /f "delims=" %%i in (b.txt) do (
set str=%%i&set /a n+=1
set _!n!=%%i
if "!str:~,4!"=="abcd" call :lp
)
set /a m=n-1
set str=!_%m%!
if "!str:~,4!"=="abcd" echo !_%n%!
pause>nul&goto :eof
:lp
if defined c echo !_%c%!
set b=%n%
set /a a=b-1,c=b+1
echo !_%a%!&echo !_%b%!