in reply to to divide/split a file to small files.
Also see part - split up files according to column value, which you could either try to reuse or adapt to your needs