# Final Fantasy IV - .DAT Container unpacker 0.1# By MaKiPL 21-06-2017# Python 2.7import structimport os.pathmypath = r'FILEPATHHERE' #TYPE FILE PATHf = open(mypath, 'r+b')magic = f.read(4)if magic!= 'SSAM': print('This is not FFIV DAT container file!') exitcount = struct.unpack('<I', f.read(4))[0]pointers = [0]sizes = [0]names = ['0']_index = 0while _index < count: pointers[_index] = struct.unpack('<I', f.read(4))[0] sizes[_index] = struct.unpack('<I', f.read(4))[0] names[_index] = f.read(32) print(pointers[_index]) print(sizes[_index]) print(names[_index]) pointers.append(0) sizes.append(0) names.append('0') _index += 1 relativeFiles = count*40+8OutputDir = os.path.dirname(mypath) + '\\' + os.path.basename(mypath)if not os.path.exists(OutputDir[:-4] + 'dec'): os.mkdir(OutputDir[:-4] + 'dec')_index = 0while _index < count: f.seek(relativeFiles+pointers[_index], 0) buff = f.read(sizes[_index]) temppath = OutputDir[:-4] + 'dec\\' + names[_index] if os.path.exists(temppath): os.remove(temppath) ff = open(temppath, 'w+b') ff.write(buff) ff.close() _index += 1 f.close()