I just tried it and it works the way you expected. What are you getting?
C:\>type test.bat set /p var="" set var=%var:~3% echo %var% C:\>test C:\>set /p var="" Hello World C:\>set var=lo World C:\>echo lo World lo World C:\>
So - it looks like you need two things: 1) Some condition for exiting your second loop. Between the label :code and goto code , when the matching condition is satisfied (i.e. if %line:~0,3% == err ) Without knowing what you need from your code, I would put something like the following
if %line:~0,3% == err echo.%line:~3% & pause & exit
This will pause and shut down when a matching string is found.
2) Some exit condition, if you reach the end of the lines, and there was no match. My suspicion is what causes the error you see, since your input file probably does not satisfy this condition.
Steven schroeder
source share