#!/usr/bin/env python2 from __future__ import with_statement import sys import optparse import os, os.path from contextlib import nested def convert(i, o): for byte in i.read(): o.write(chr(ord(byte) ^ 34)) if __name__ == "__main__": p = optparse.OptionParser(usage="%prog file") options, args = p.parse_args() for name in args: bname = os.path.splitext(os.path.basename(name))[0] print "converting %s" % bname with nested(file(name), file("%s.mp3" % bname, "w")) as (i, o): convert(i, o)