#! /bin/bash
# saumlfix.sh 1.0
# Removes all swedish umlauts in a directory's name, files and subdirectories, recursively.
# Takes an directory as argument, you MUST include a trailing slash (/).
# Copyright tobbez 2006.
for i in ${1}*
do
	# Generate new name
	newName=`echo "${i}" | tr "åäöÅÄÖ" "aaoAAO"`

	# Fix readability of output
		oldLen=`echo -n "${i}" |wc -c`
		let spaces=50-$oldLen
		spacesString=""

		for j in `seq 1 $spaces`
		do
			spacesString="$spacesString "
		done
	# End readability fix

	# Move it!
	echo "Moving ${i}${spacesString}->  $newName"
	mv "${i}" "$newName"

	# Recurse if directory
	type=`file "$newName" | awk '{print $2}'`
	if [ "${type}" = "directory" ]
	then
		echo "Recursing into $newName"
		$0 "${newName}/"
	fi
done
