Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!
Credits 38 Posts 17 Joined 2006-10-12 01:25 19-year member UID 65383
Status Offline
I have a txt file with a total of ten thousand lines of numbers. Now I need to split it into multiple files, with 400 lines of numbers in each file. How should the DOS command be written?
Credits 788 Posts 366 Joined 2006-12-31 02:43 19-year member UID 75048 Gender Male
Status Offline
This thing seems to be more than 10K lines after all...
Forget it, it doesn't affect anything. I modified the code in reply #2 a bit. No delayed variables needed; I used the call method instead.
@echo off
set /a count=0
set /a t=1
for /f "delims=" %%a in (test.txt) do call :doit %%a
goto :eof
:doit
set /a count+=1
echo %1 >>%t%.txt
if %count% geq 400 set /a count=0 && set /a t+=1