Skip to content

Instantly share code, notes, and snippets.

@demofly
Created April 3, 2014 15:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save demofly/25f856a96c29b89baa32 to your computer and use it in GitHub Desktop.
Save demofly/25f856a96c29b89baa32 to your computer and use it in GitHub Desktop.
A batch script converts (inplaces) all files in a directory to utf-8
#!/bin/bash
apt-get -y install recode uchardet > /dev/null
find "$1" -type f | while read FFN # 'dir' should be changed...
do
encoding=$(uchardet "$FFN")
echo "$FFN: $encoding"
enc=`echo $encoding | sed 's#^x-mac-#mac#'`
set +x
recode $enc..UTF-8 "$FFN"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment