#!/bin/bash
EXTENSIONS="ini inc php tpl sql html js"
 
function convertFiles {
  F=`find . -name "*.$1"`
  for I in $F ; do
    UTF=`file -i $I | grep 'UTF-8' | wc -l`
    if [ ${UTF} -eq 0 ] ; then
      echo $I
      cat $I | iconv -f iso_8859-2 -t utf8 >/tmp/$$
      cp /tmp/$$ $I
    fi
  done
}
 
for I in $EXTENSIONS ; do
  convertFiles $I
done
 
chown 33.33 * -R
find . -type f -exec chmod 660 {} \;
find . -type d -exec chmod 770 {} \;

