import os from subprocess import check_output, DEVNULL from from_root import from_root for file in os.listdir(from_root("output_badges")): if file.endswith(".pdf"): outfile_name = file.split(".pdf")[0] outfile_name += "-print.pdf" check_output( ["pdfjam", file, "--nup", "1x2", "--paper", "a4paper", "--noautoscale", "true", "--outfile", outfile_name], stderr=DEVNULL )