On Fri, 26 Jun 1998, Cui Jian wrote:
> I just migrate my web file form Windows NT to
> Linux, in NT,the file name is uppercase, now I
> need lowercase file name. How to do this. I know
> the "tr" command can to this, but I don't
> familiar with linux command. and body can help
> me ? Thanks a lot.
>
There are many, many ways to do this.
I've attached a small script to to give you an
example of using the "tr" command and some shell
globing.
--
John Darrah (u05192) | Dept: N/C Programming
Giddens Industries |
PO box 3190 | Ph: (206) 767-4212 #229
Everett WA 98203 | Fx: (206) 764-9639
#!/bin/bash
#
Usage () {
echo "Usage: fcase u|l <files> ..."
echo " l = lowercase files"
echo " u = uppercase files"
exit 1
}
[ $# -le 1 ] && Usage
C=$1
shift
[ ${C%[ul]} ] && Usage
for F in $*
do
[ -e $F ] || {
echo "file not found: $F"
continue
}
D=${F%/*}
N=${F##*/}
[ ${D%$N} ] || D="."
case $C in
u) NN=$(echo $N | tr a-z A-Z) ;;
l) NN=$(echo $N | tr A-Z a-z) ;;
esac
[ ${N%$NN} ] || {
echo "no change: $NN"
continue
}
mv -v $D/{$N,$NN}
done
# End