В итоге я написал небольшой скрипт на Python 2 для достижения этой цели.
# Author: Alex Finkel
# Email: alex@finkel.net
# This program splits a large binary file into smaller pieces, and can also
# reassemble them into the original file.
# To split a file, it takes the name of the file, the name of an output
# directory, and a number representing the number of desired pieces.
# To unsplit a file, it takes the name of a directory, and the name of an
# output file.
from sys import exit, argv
from os import path, listdir
def split(file_to_split, output_directory, number_of_chunks):
f = open(file_to_split, 'rb')
assert path.isdir(output_directory)
bytes_per_file = path.getsize(file_to_split)/int(number_of_chunks) + 1
for i in range(1, int(number_of_chunks)+1):
next_file = open(path.join(output_directory, str(i)), 'wb')
next_file.write(f.read(bytes_per_file))
next_file.close()
f.close()
def unsplit(directory_name, output_name):
assert path.isdir(directory_name)
files = map(lambda x: str(x), sorted(map(lambda x: int(x), listdir(directory_name))))
out = open(output_name, 'wb')
for file in files:
f = open(path.join(directory_name, file), 'rb')
out.write(f.read())
f.close()
out.close()
if len(argv) == 4:
split(argv[1], argv[2], argv[3])
elif len(argv) == 3:
unsplit(argv[1], argv[2])
else:
print "python split_large_file.py file_to_split output_directory number_of_chunks"
print "python split_large_file.py directory name_of_output_file"
exit()