from ox.text import findRe def do(): f = open("ChronoArr_Srt.txt") txt = f.read() tapes = txt.split("***") indexHtml = '' counter = 1 for t in tapes: fullTxt = t.strip() titleReg = r'Title: (.*?)\n' timeReg = r'Time: (.*?)\n' time = findRe(fullTxt, time) outfile = "tapes/%d.html" % (counter,) title = findRe(fullTxt, titleReg) print title indexHtml += "%s
Time: %s

\n" % (outfile, title, time,) out = open(outfile, "w") out.write("
%s
" % (fullTxt,)) out.close() counter += 1 indexFile = open("index.html", "w") indexFile.write(indexHtml) indexFile.close() f.close()