Take a look at split and File::Split.
In reply to Re: Split a file by gopalr in thread Split a file by swift