Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import sys
- splitsz = 524288
- zerofill = True
- if len(sys.argv) > 1:
- baseName = sys.argv[1]
- bank = 0
- try:
- with open(baseName, mode='rb') as InFile:
- file_data = InFile.read()
- sz = len(file_data)
- while sz > splitsz:
- OutFile = open("%s.b%d" % (baseName, bank), "wb")
- OutFile.write(file_data[bank*splitsz:(bank+1)*splitsz])
- OutFile.close()
- bank += 1
- sz -= splitsz
- if sz:
- OutFile = open("%s.b%d" % (baseName, bank), "wb")
- OutFile.write(file_data[bank*splitsz:])
- if zerofill:
- l = [0]*(splitsz - sz)
- OutFile.write(bytearray(l))
- OutFile.close()
- except:
- print("Cannot open file '%s'!" % (baseName))
- else:
- print("Please give the source file name as parameter")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement