28 lines
882 B
Python
28 lines
882 B
Python
#!/usr/bin/env python3
|
|
|
|
import glob, os, time, re, argparse
|
|
|
|
parser = argparse.ArgumentParser(description="converts a folder of animation frames (.txt) to .van", epilog="Made by MrV on IRC")
|
|
parser.add_argument("dirpath", help="path of folder to convert")
|
|
parser.add_argument("-o", "--output", help="path of output file (.van)", required=True)
|
|
args = parser.parse_args()
|
|
dirpath = args.dirpath
|
|
outpath = args.output
|
|
|
|
print("Preparing...")
|
|
files = glob.glob(os.path.join(dirpath, "*.txt"))
|
|
# https://stackoverflow.com/a/53694164 :)
|
|
files = sorted(files, key=lambda x:float(re.findall("(\d+)",x)[0]))
|
|
|
|
print("Reading...")
|
|
frames = []
|
|
for file in files:
|
|
with open(file, "rb") as f:
|
|
raw = f.read()
|
|
frames.append(raw)
|
|
|
|
print("Writing...")
|
|
output = b"\x1b<VAN>\x1b".join(frames)
|
|
with open(outpath, "wb") as h:
|
|
h.write(output)
|
|
print("Saved to " + outpath) |