def convert_filename(txtfilename, outdir='.'):
    """Convert a .TXT filename to a Therion .TH filename"""
    return os.path.join(outdir, os.path.basename(txtfilename)).rsplit('.', 1)[0] + '.th'
Convert a .TXT filename to a Therion .TH filename