Though it may take hell lot of a time for me to understand this piece of code, this is a very useful Windows batch script split a text file based on number of lines. The condition is both the input file and output directory should exist. Number of lines is specified as MaxLines.
REM Can not be larger than 2147483648 !!!
if not exist “%InFile%” (
echo *ERROR* Input file does not exist!
if not exist “%OutDir%\” (
echo *ERROR* Output folder does not exist!
for %%A in (“%InFile%”) do (
set /a Line=MaxLines+1
for /f “usebackq tokens=*” %%A in (“%InFile%”) do (
set /a Line+=1
if !Line! GTR %MaxLines% (
set /a File+=1
if exist “!OutFile!” del “!OutFile!”