Skip to content

Instantly share code, notes, and snippets.

@markuman
Created September 15, 2015 06:36
Show Gist options
  • Save markuman/356fb84962eca6898536 to your computer and use it in GitHub Desktop.
Save markuman/356fb84962eca6898536 to your computer and use it in GitHub Desktop.
converts all ISO-8859 files to UTF-8
#!/bin/bash
function convert(){
ENCODING=$(file "$1" |awk '{print$2}')
if [[ "$ENCODING" = "ISO-8859" ]]; then
iconv -f iso-8859-15 -t utf-8 "$1" > tmp.file
mv tmp.file "$1"
rm tmp.file
fi
}
export -f convert
find . -type f -exec bash -c 'convert $1 "{}"' \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment