How to change case of filenames under bash or Bourne???

How to change case of filenames under bash or Bourne???

Post by Pete Holsbe » Sat, 27 Apr 1996 04:00:00



How can I change a bunch of filenames that are in uppercase
(with digits) to lowercase (with digits) using bash or sh?

Thanks,
Pete

 
 
 

How to change case of filenames under bash or Bourne???

Post by David B. Chorli » Sat, 27 Apr 1996 04:00:00



Quote:>How can I change a bunch of filenames that are in uppercase
>(with digits) to lowercase (with digits) using bash or sh?

#! /bin/sh
for i in $*
do
        j=`echo $i | tr 'A-Z' 'a-z'`
        mv $i $j
done

The tr command might have to be tr '[A-Z]' '[a-z]'; test it
on your system.

Quote:>Thanks,
>Pete

--
David B. Chorlian
Neurodynamics Lab  SUNY/HSCB



 
 
 

How to change case of filenames under bash or Bourne???

Post by Don Bla » Sun, 28 Apr 1996 04:00:00



: How can I change a bunch of filenames that are in uppercase
: (with digits) to lowercase (with digits) using bash or sh?

for x in `ls `
 do
 bar=`echo $x | tr /A-Z/, /a-z/ `
 mv $x $bar
 done

 
 
 

How to change case of filenames under bash or Bourne???

Post by Louis Kat » Mon, 29 Apr 1996 04:00:00





>: How can I change a bunch of filenames that are in uppercase
>: (with digits) to lowercase (with digits) using bash or sh?

>for x in `ls `
> do
> bar=`echo $x | tr /A-Z/, /a-z/ `
> mv $x $bar
> done

Here are a few more ways as well:

     for i in * ; do
         mv $i `echo $i | tr '[A-Z]' '[a-z]'`
     done

Or:

        for i in *
          do
            j="$i"
            typeset -u j
            mv $i $j
          done

Or:

    for i in * ; do
        mv $i `echo $i | sed \
        -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
    done

Or:


Or for zsh:

        % foreach k (*)
        ? mv $k ${(L)k}
        ? end

Louis Kates

 
 
 

How to change case of filenames under bash or Bourne???

Post by Rich K » Mon, 29 Apr 1996 04:00:00




>How can I change a bunch of filenames that are in uppercase
>(with digits) to lowercase (with digits) using bash or sh?

>Thanks,
>Pete

 in ksh

 /bin/ksh

 typeset -l newname

 for i in $*
 do
         newname=$i
         mv $i $newname
done

--------

in perl

 /usr/bin/perl


        ($newname = $_ ) =~ tr/A-Z/a-z/;
        rename $_ $newname;

Quote:}

   richk