check below command if it helps:
Note you should have some filter string names against which you split files. In this case each file will begin with the string "XYZ".
if "%~1"=="" echo Bad filename & exit /b
if not exist "%~f1" echo Cannot find %~1 & exit /b
for /f "tokens=1,* delims=]" %%a in ('type "%~nx1" ^| find /n /v ""') do (
if "!str:~0,3!"=="XYZ" (
set /a count+=1
echo Creating file: !count!
other case use this ABC.txt is the file name and it would be extracted from line content
for /f "delims=<> tokens=1" %%L in (ABC.txt) do (
set /A IDX+=1
please send me exact file sample and result outputs you want... will try to help you further.