Basically what I am trying to do here is cutting the huge txt file into different txt files (i.e. test0.txt, test1.txt, test2.txt, test3.txt ....)
> open txt file > cut 50 lines > paste 50 lines into new txt file
Cheers, DB

Moderator: DosItHelp
Code: Select all
c:\test> split -l 50 file
Code: Select all
setlocal enabledelayedexpansion
:: Starts splitting at 0-index, that is, test0.txt instead of test1.txt.
set filecounter=0
for /f "delims=" %%x in (mytext.txt) do (
set /a linecounter+=1
echo:%%x>>test!filecounter!.txt
if !linecounter!==50 set /a linecounter=0,filecounter+=1
)
Code: Select all
setlocal enabledelayedexpansion
:: Starts splitting at 0-index, that is, test0.txt instead of test1.txt.
set filecounter=0
for /f "delims=] tokens=1*" %%x in ('type mytext.txt ^| find /v /n ""') do (
set /a linecounter+=1
echo:%%y>>test!filecounter!.txt
if !linecounter!==50 set /a linecounter=0,filecounter+=1
)
ghostmachine4 wrote:download coreutil for windows and then you can use split commandCode: Select all
c:\test> split -l 50 file
orange_batch wrote:Keep in mind that DOS always appends a line return to the end of a line, so there will be a line return at the end of line 50.
This will skip blank lines in mytext.txt.Code: Select all
setlocal enabledelayedexpansion
:: Starts splitting at 0-index, that is, test0.txt instead of test1.txt.
set filecounter=0
for /f "delims=" %%x in (mytext.txt) do (
set /a linecounter+=1
echo:%%x>>test!filecounter!.txt
if !linecounter!==50 set /a linecounter=0,filecounter+=1
)
This will not skip blank lines in mytext.txt.Code: Select all
setlocal enabledelayedexpansion
:: Starts splitting at 0-index, that is, test0.txt instead of test1.txt.
set filecounter=0
for /f "delims=] tokens=1*" %%x in ('type mytext.txt ^| find /v /n ""') do (
set /a linecounter+=1
echo:%%y>>test!filecounter!.txt
if !linecounter!==50 set /a linecounter=0,filecounter+=1
)
ghostmachine4 wrote:download coreutil for windows and then you can use split commandCode: Select all
c:\test> split -l 50 file
deibertine wrote:ghostmachine4 wrote:download coreutil for windows and then you can use split commandCode: Select all
c:\test> split -l 50 file
Ok I do see on whats going on with this.
Basically doing this c:\test> split -l 50 file
Resulted tons of file.txtaa , file.txab , file.txac so forth...
and also displays the file into one line in each txtaa txtab ....
Is it possible to cut/paste then place the copied text to a file but in a vertical arrangement?
text
text
text
not like this:
texttexttext