On Mon, 29 Jan 2001, Kurth Bemis wrote:
> thanks to Microsoft and their wisdom i now have ~200 files that used to be
> all lowercase...now their all caps. their web sites so now everything is
> broken. does anyone know or a util or a script that will let me make all
> the filenames lowercase?
See attached. YMMV, may format your hard drive, etc, etc. But it works for
me. :-) Specify files to fix on the command line. If you specify a
directory, this script will desend into it, and all files and directories in
it will be processed, recursively.
--
Ben Scott <[EMAIL PROTECTED]>
Net Technologies, Inc. <http://www.ntisys.com>
Voice: (800)905-3049 x18 Fax: (978)499-7839
#!/bin/bash2
function do_me {
local i new_name
for i in "$@" ; do
if [[ $i = . ]] || [[ $i = .. ]] ; then
# skip current and parent directories
continue
fi
if [[ -d $i ]] ; then
# desend into directories
cd $i
do_me .* *
cd ..
fi
# translate name
new_name=$( echo $i | tr A-Z a-z )
if [[ $i = $new_name ]] ; then
# new_name matches original
continue
fi
if [[ -e $new_name ]] ; then
echo "cannot rename $i to $new_name: target already exists"
continue
fi
mv "$i" "$new_name"
done
}
do_me "$@"