Counting lines in a text file; use result to split text files into sections -


using windows batch or possibly language looking split text file containing 85k+ results separate text files. there header @ top needs present on every new text file.

the short code have , can work follows;

find "" /v /c /n "d:\users\ashley.fayers\desktop\m6_040615\m6_040615_b_full\m6_040615_b.txt" 

this code provides me number of lines in text includes header need not include. need include in later created text files.

edit: number of header lines added

@echo off setlocal enabledelayedexpansion  set "thefile=d:\users\ashley.fayers\desktop\m6_040615\m6_040615_b_full\m6_040615_b.txt" set headerlines=25  /f %%a in ('find /c /v "" ^< "%thefile%"') set /a totallines=%%a-headerlines call :splitfile < "%thefile%" goto :eof   rem split file in parts 10,000 lines each  :splitfile  /l %%i in (1,1,%headerlines%) set /p header[%%i]= set /a part=0, numlines=10000  :nextpart    set /a part+=1    if %totallines% lss %numlines% set numlines=%totallines%    (       /l %%i in (1,1,%headerlines%) echo(!header[%%i]!       /l %%i in (1,1,%numlines%) (          set "line="          set /p line=          echo(!line!       )    ) > part%part%.txt    set /a totallines-=numlines if %totallines% gtr 0 goto nextpart exit /b 

Comments

Popular posts from this blog

symfony - TEST environment only: The database schema is not in sync with the current mapping file -

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -