#!/usr/bin/env python3 import glob def snafu(t, s, r): l = t while l.find(s) != -1: l = l.replace(s, r) return l for n in glob.glob("tmp/body/*.body"): f = open(n, "r"); t = f.read() f.close() t = snafu(t, "

", "

") t = snafu(t, "

", "

") t = snafu(t, "


", "") t = snafu(t, "\n
", "\n") t = snafu(t, "
", "") t = snafu(t, "\n
", "\n") t = snafu(t, "


", "

") f = open(n, "w"); f.write(t) f.close()