Wednesday, April 8, 2009

Converting charset enconding of a bunch o .tex files

A friend of mine came to me asking for a simple way to convert the charset encoding of a bunch o LaTeX files. He had all his files in the UFT-8 encoding and he wanted to convert all of them to "latin-1" (ISO-8859-1).

So, I saved all the files he sent me in the same folder, opened a terminal shell window and typed the following command line:

ls -1 *.tex | while read line ; do iconv -f utf-8 -t iso-8859-1 $line -o "latin1_"$line; done

And voilà, they were now encoded with ISO-8859-1.

No comments:

Post a Comment