#! /bin/bash
# Script to convert file names from Latin-9 to UTF-8 recursively
# by Rémi Denis-Courmont, 2005.
# This script is placed in the public domain.

function convdir
{
	pushd -- "$1" >/dev/null || exit 1

	for oldname in *; do
		# recursion
		if [ -d "$oldname" ]; then
			convdir "$oldname"
		fi

		echo "$oldname" | \
		if ! iconv -f utf8 -t utf8 >/dev/null 2>&1 ; then
			newname="`echo -n "$oldname"| iconv -f iso8859-15 -t utf8`"
			mv -v -- "$oldname" "$newname" || exit 1
		fi
	done
	popd >/dev/null
}

while [ "$1" ]; do
	convdir "$1"
	shift
done

