On Monday 02 July 2007 22:47, Alex Schuster wrote:
> Mich writes:
> > I backed up my wife's WinXP fs using K3B and I used default settings
> > which unfortunately converted all file names to CAPITALS and shortened
> > them to 8 characters maximum, just like DOS would do.  Is there a clever
> > way to change some of them back to lower case (in batches within given
> > directorates) so that she doesn't have to do it manually one by one?  I
> > do not want to change the access times, only the filename case letters.
>
> Create a script like this, name it lowercase.sh or something, and call it
> with "lowercase file1 file2 dir1 dir2". I takes a list of files as
> arguments (use * for all), and also works for directories.
> So, "lowercase ." should convert all files and directories to lowercase.
>
> Put the script into your $PATH, or precede it by its path, e.g.
> ./lowercase. To test it before possible messing up (I just wrote this
> quickly) use the -t option: lowercase -t /path/to/your/files
>
>
> #!/bin/bash
>
> # parse options (-t only)
> while getopts "t" opt
> do
> 	case $opt in
> 	t )
> 		test=true
> 		;;
> 	* )
> 		exit 1
> 	esac
> done
>
> shift $(( OPTIND-1 ))
>
> # loop over arguments
> while (( $# ))
> do
> 	file=$1
> 	if [[ -d $file ]]
> 	then
> 		# call myself
> 		$0 ${test:+-t} "$file"/*
> 	elif [[ -f $file ]]
> 	then
> 		# conversion to lowercase
> 		  dir=$( dirname  "$file" )
> 		 base=$( basename "$file" )
> 		lower=$( echo "$base" | tr '[:upper:]' '[:lower:]' )
> 		newfile=${dir:+$dir/}$lower
> 		[[ $file -ef $newfile ]] ||
> 			${test:+echo} mv -v "$file" "$newfile"
> 	else
> 		echo "File not found: '$1'"
> 	fi
> 	shift
> done
>
>
> 	Alex

Thanks Alex, I was trying your script, but just like Etaoin's script it does 
not go beyond level 1 in the directory.  All the subdirectories and files 
within them stay in Capital Case.

How can I change it to recursively look into the directory?
-- 
Regards,
Mick