Skip to content

Instantly share code, notes, and snippets.

@gsouf
Created February 14, 2014 13:38
Show Gist options
  • Save gsouf/9001102 to your computer and use it in GitHub Desktop.
Save gsouf/9001102 to your computer and use it in GitHub Desktop.
Recursively convert encoding of all files in a project
encodeTo="UTF-8"
# CHANGE THE PATTERN IF NEEDED
for filename in ` find . -type f -name "*.php"`
do
echo $filename
enc=`file -bi $filename | awk -F"charset=" '{print $2}'`
iconv -f $enc -t $encodeTo $filename -o $filename
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment