I want a batch file to move the first 8 lines of master.txt to second.txt and save both files. Second.txt will always be overwritten with the new 8 lines each time the batch is run. If moving is not possible, then just copy the first 8 lines to second.txt this time, and then overwrite it with the next 8 lines each time I run the batch.
Each line of the file contains several special characters and leading spaces, and some blank lines that must be copied to the new file.
::edlin is easiest, if just using batch:
@goto :10
9,#d
e
:10
copy /y master.txt second.txt
edlin second.txt < %0.bat
If #1 does it, great. Otherwise post enough of them file to see what we're dealing with.
=====================================
Helping others achieve escape felicityM2
Response #1 did half of what I needed to do, but did not get the next 9 lines when I ran the batch the second time. I think it could be promising if I put the edlin commands in separate files and run edlin twice, once on the second.txt to remove everything after the 9th line and once on master.txt to remove the first 9 lines. If this works, it will gradually reduce master.txt by 9 lines at a time to become an empty file. That is OK, since the master.txt file is expendable.
I have tried this with the external edlin command text files and it appears to work well, although it creates a small square character as the last item in the both files. I don't know what it is or how to prevent it. I have tried adding /B when running edlin. Any ideas?
Nevermind, that character did not cause any problems and everything works well. Thank for your help.
@echo off > Second.txt & @echo off > newfile & setLocal enableDELAYedeXpansion for /f "tokens=1* delims=[]" %%a in ('find /n /v "" ^< master.txt') do (
if %%a leq 8 >> second.txt echo.%%b
if %%a gtr 8 >> newfile echo.%%b
)
move /y newfile master.txt
=====================================
Helping others achieve escape felicityM2
Yes (14) | ![]() | |
No (14) | ![]() | |
I don't know (15) | ![]() |