Batch converting files from iso-8859-1 to utf-8

I’ve already posted on how to convert a single file from one encoding to another (iso-8859-1 to utf-8 in this example). But how to do it for a large amount of files, let’s say LaTeX source files for example, in one go?

Here’s a little bash one-liner that could help:

find ~ -type f -name "*.tex" -exec sh -c '
  f="{}"
  iconv --from-code=ISO-8859-1 --to-code=UTF-8 -- "$f" > "$f".tmp
  mv -v -- "$f".tmp "$f"
  ' \;

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.