Removing accents from filenames in a directory tree

The following shell script can be used to remove accents from filenames in a directory and all subdirectories.

#!/bin/bash
 
function dodir() {
    pushd "$1" >> /dev/null
    for x in *; do
        trans=`echo "$x" | tr "éáóüűúöóíÉÁÓÜŰÚÖÓÍ" "eaouuuooiEAOUUUOOI" | tr -c "[:alnum:]!@#$%^&_,' ()[].\n-" "#"`
        if [ "$trans" != "$x" ]; then
            echo "must rename $x to $trans"
            mv "$x" "$trans"
            if [ -d "$trans" ]; then
                dodir "$trans"
            fi
        else
            if [ -d "$x" ]; then
                dodir "$x"
            fi
        fi
    done
    popd >> /dev/null
};
 
dodir "$1"