import glob

with open("all_rules.tex", 'w') as f:
    f.write("\\documentclass[a4paper]{report}\n")
    f.write("\\usepackage{graphicx}\n")
    f.write("\\begin{document}\n")

    for inp in sorted(glob.glob("*.eps")):
        f.write(open("template.tex", 'r').read().replace("FILE", inp).replace("NAME", inp[5:-4].replace("_", " ")))

    f.write("\\end{document}\n")
