HELP converting filenames!
Rahul Dhesi
dhesi at sun505.UUCP
Sun Oct 8 13:29:27 AEST 1989
In article <1983 at convex.UUCP> tchrist at convex.COM (Tom Christiansen) writes:
>I second the "shame on you"; lwall's rename script posted in reponse to
>this subject thread was the most powerful, yet small and elegant, such
>thing that the I've ever seen.
#! /bin/sh
# converts filenames to lowercase without zapping mixed-case names
# -- Rahul Dhesi, Oct 1989
# (powerless, big-gish, inelegant, but *portable-ish*)
for f in "$@"
do
case "$f" in
*[a-z]*)
#echo "skipping $f, contains lowercase chars"
;;
*)
newname=`echo "$f" | tr 'A-Z' 'a-z'`
if test "$newname" != "$f"
then
if test -f "$newname"
then
echo "$newname already exists"
else
mv "$f" "$newname"
fi
fi
;;
esac
done
By the way, those intellectually inclined may want to find the one
significant remaining bug in the above script.
Rahul Dhesi <dhesi%cirrusl at oliveb.ATC.olivetti.com>
UUCP: oliveb!cirrusl!dhesi
More information about the Comp.unix.wizards
mailing list