#! /home/phd/.local/bin/python3 "iconv wrapper" import os, shutil, tempfile from recode_filenames import parse_args from_encoding, to_encoding, files = parse_args(default='-') tempfname = "_iconvx" + tempfile.gettempprefix() + "tmp" if files != ['-']: try: for file in files: os.system( "iconv.py -f '%s' -t '%s' '%s' > '%s'" % ( from_encoding, to_encoding, file, tempfname)) shutil.copy2(tempfname, file) finally: os.unlink(tempfname) else: # filter stdin => stdout os.system("iconv.py -f '%s' -t '%s'" % (from_encoding, to_encoding))