#!/usr/bin/python3

import argparse
import subprocess
import sys

parser = argparse.ArgumentParser()
parser.add_argument("filepath", help="The PDFs to split.")
args = parser.parse_args()
filepath = args.filepath

if not filepath.lower().endswith(".pdf"):
    print("The indicated file must be a PDF.")
    exit()

output = filepath[:-4] + '_%02d' + filepath[-4:]

cmd = ['pdftk', filepath, 'burst', 'output', output, 'compress']
subprocess.run(cmd)
