#!/bin/bash ICONVBIN='/usr/bin/iconv' # path to iconv binary ORIGINAL_IFS=$IFS IFS=$'\n' if [ $# -lt 3 ] then echo "$0 dir from_charset to_charset" exit fi find . -type f -print | while read f do if test -f $f then files=$(echo "$f" | egrep "((\.php)|(\.html?)|(\.txt)|(\.sql)|(\.mkf)|(\.xml)|(\.css)|(\.js))$") if [ -n "$files" ] then echo "Converting $files" /bin/mv $f $f.old $ICONVBIN -f $2 -t $3 $f.old > $f rm -f $f.old fi else echo "Skipping $f - not a regular file"; fi done IFS=$ORIGINAL_IFS