Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
split files
#1
Hi..

Can somebody help me with the following?

I have a file new.txt it is a large file, i want it splitted up in files of 3000 lines. and written down in c:\export\new-1.txt and the following c:\export\new-2.txt etc till end of file...

anybody an idea?

thanks
#2
Macro
Code:
Copy      Help
;change these
str sFile="$desktop$\led.txt" ;;large file
str destFolder="$desktop$\936543" ;;destination folder
int nLinesInFile=3000 ;;number of lines in small files
int enable=0 ;;change to 1 to create the files. By default, just displays file paths.

;____________________________________

if(enable) mkdir destFolder
destFolder+"\new-%i.txt"

str s s1 s2 s3
s1.getfile(sFile)
int i j
foreach s s1
,s2.addline(s)
,i+1
,if(i=nLinesInFile)
,,;g1
,,j+1
,,s3.format(destFolder j)
,,out "%s (%i lines)" s3 i
,,if(enable) s2.setfile(s3)
,,s2=""
,,i=0

if(s2.len) goto g1


Forum Jump:


Users browsing this thread: 1 Guest(s)