Use case: ======= 1. OSX 10.7, bunch of .tex files culled from a blog via some cruddy old Perl script. .tex files are utf-8 encoded, which means the quotes and apostrophes drop out going through pdflatex. 2. Recommend using git to manage the .tex files, which are all in a /src directory in the project. If you're going to do batch edits, You Will Need to branch, realize you gooned up, and roll back. 3. Understood, sed is the more classical tool here, except that I could not it to work in my OSX terminal.
Invocation: ======= python charfix.py `ls src/*.tex` charfix.py code: ======= # -*- coding: utf-8 -*- import fileinput def process(line): print line.replace( "’", "'" ).replace( "“", '"' ).replace( "”", '"' ) if __name__=="__main__": for line in fileinput.input( inplace=1 ): process(line) ======= Discussion: ======= Thank you, python! -- http://mail.python.org/mailman/listinfo/python-list