Solved How to find certain line then import line batch

July 5, 2019 at 11:18:09
Specs: Windows 10
I am using a batch that opens SQL, exports to a text file.
I want to search this file through batch file and find line 3 then import this line 3 into another file on a certain line 15.
Currently it is only using the last line of the file no matter what i put as the for /F "skip=4 delims="
I can provide the full batch if needed.

See More: How to find certain line then import line batch

Report •

July 5, 2019 at 18:24:30
✔ Best Answer
if you actually want line 3, the skip should be skip=2. Note that batch does not recognize null lines as lines but since this is an export-to-text, that should not matter.
You need to exit the loop, otherwise it runs till end-of-file:
for /f "skip=4 tokens=*" %%a in (test) do (
>line4 echo %%a
goto :done
type line4
::------ end snippet

I used your original skip value, and sent output to a single-line text file because "set" sometimes has problems with special characters. Try this and see if file 'line4' looks like what you want, and of course replace 'test' with your exported-text filename, and also of course any file called 'line4' will be destroyed!

Report •
Related Solutions

Ask Question