Findstr without pipe
Posted: 18 Jun 2018 01:12
I am using a this batch script to extract a part of a binary file following a delimiter string:
This is working fine, but with some files I get the error messages "Line ... too long". I know that this problem is associated to piping. I also found the tip:
"The line too long error only happens when FINDSTR reads the input via redirection or a pipe. That error goes away if you pass the name (path) of the file directly to FINDSTR."
My understanding of batch-command syntax is too poor to find out how this could be done in my above script. Can someone here help?
Cheers.
Code: Select all
@echo off
setlocal enabledelayedexpansion
REM Line number of the delimiter line:
for /F "delims=:" %%a in ('findstr /N "^xxyyzz" "Input.bin"') do set "lines=%%a"
echo %lines%
REM Extract the part of the Input.bin following the delimiter line:
< "Input.bin" (
REM Pass thru the first lines:
for /L %%i in (1,1,%lines%) do set /P "="
REM Copy the rest to output bin:
findstr "^"
) > Output.bin
"The line too long error only happens when FINDSTR reads the input via redirection or a pipe. That error goes away if you pass the name (path) of the file directly to FINDSTR."
My understanding of batch-command syntax is too poor to find out how this could be done in my above script. Can someone here help?
Cheers.