Change Upper case filename to lower case filename

Change Upper case filename to lower case filename

Post by cw.Li » Wed, 02 Jul 1997 04:00:00



Hi:

We would like to know is there solutions for change filenames from
uppercase to lower case in UNIX ? ( eg shellscript or C-program  to
perform on multiple files which filename all in Upper-case ).

Thank you in advanced.

Best Regards.
C.W.Lin

 
 
 

Change Upper case filename to lower case filename

Post by Herve Couppe de Lahongrais - CD » Wed, 02 Jul 1997 04:00:00



> Hi:

> We would like to know is there solutions for change filenames from
> uppercase to lower case in UNIX ? ( eg shellscript or C-program  to
> perform on multiple files which filename all in Upper-case ).

> Thank you in advanced.

> Best Regards.
> C.W.Lin


#!/bin/sh

for i
do
        upper=$i
        lower=`echo $upper | tr [:upper:] [:lower:]`

        mv $upper $lower
done
--
Herve Couppe de Lahongrais (SEU)       | Eurocontrol Experimental Centre


 
 
 

Change Upper case filename to lower case filename

Post by Paul Josli » Wed, 02 Jul 1997 04:00:00



> Hi:

> We would like to know is there solutions for change filenames from
> uppercase to lower case in UNIX ? ( eg shellscript or C-program  to
> perform on multiple files which filename all in Upper-case ).

Which sh?

#!/bin/ksh
for i in *
do
    typeset -l j=$i
    [ "$i" != "$j" ] && mv $i $j && echo $i $j
done

--
Paul R. Joslin           The man who sets out to carry a cat by its tail learns

+1 513 576 2012          will grow dim or doubtful.  -- Mark Twain.

 
 
 

Change Upper case filename to lower case filename

Post by Mark Greatri » Thu, 03 Jul 1997 04:00:00



>Hi:

>We would like to know is there solutions for change filenames from
>uppercase to lower case in UNIX ? ( eg shellscript or C-program  to
>perform on multiple files which filename all in Upper-case ).

>Thank you in advanced.

>Best Regards.
>C.W.Lin


One way you could do it is via something like this:-

-   for FNAME in *
-   do
        -          UPPERFNAME=`echo $FNAME | tr "[a-z]" "[A-Z]" `
-          mv $FNAME $UPPERFNAME        # insert echo to test!!!!
-   done

I'm sure there's an easier way to do this, but hell, it works for me!!!!!!
Mark

 
 
 

Change Upper case filename to lower case filename

Post by Francesco P. Lovergi » Thu, 03 Jul 1997 04:00:00


: Hi:

: We would like to know is there solutions for change filenames from
: uppercase to lower case in UNIX ? ( eg shellscript or C-program  to
: perform on multiple files which filename all in Upper-case ).

There are many methods. A very powerful solution for renaming is
a perl script. But for your simple problem:

mv $filename `echo $filename|dd conv=lcase`

: Thank you in advanced.

: Best Regards.
: C.W.Lin

--

PLEASE, REMOVE ANTI-SPAM SUFFIX BEFORE REPLY

 
 
 

Change Upper case filename to lower case filename

Post by Daniel Jam » Thu, 03 Jul 1997 04:00:00




Quote:>Hi:

>We would like to know is there solutions for change filenames from
>uppercase to lower case in UNIX ? ( eg shellscript or C-program  to
>perform on multiple files which filename all in Upper-case ).

No need to bring out a Sledge Hammer to take care of a Tack Hammer's job, as
posted by some of the others.

With PERL:

#!/usr/bin/perl
#
# Rename all files in current directory to lower case.

  foreach (<*>) {
      $newname = lc($_);
      print `mv -v $_ $newname`;
  }

----------

With SH:

#!/bin/sh
#
for file in [A-Z]*
do
   old=`echo ${file} | tr '[A-Z]' '[a-z]'`
   mv ${file} ${old}
done

--
                  ________________________________________________
                 |================================================| ---
           I---, |-=| Daniel James |=- Linux/Unix/Freedom Bigot -=|  ----
      -----U ==| |================================================|   ---

  ----'----U   | |________________________________________________|   ---
 |)___()  'U   |______====____   \________________________________|  -----
[_/,-,\"--"----- // ,-,  ,-,\\\   |/         //,-,  ,-,  ,-,\\ __#  ---    
  ( 0 )====#####// ( 0 )( 0 )''-  o          '( 0 )( 0 )( 0 )''    
---'-'--------------'-'--'-'-------------------'-'--'-'--'-'--------------

 
 
 

Change Upper case filename to lower case filename

Post by Randy Howar » Fri, 04 Jul 1997 04:00:00


This convert all filenames in a directory from upper- to lower-case:

        for file in *
        do
        mv $file `echo $file |dd conv=lcase 2>/dev/null`
        done                                          

Hope this helps.

Randy Howard


> Hi:

> We would like to know is there solutions for change filenames from
> uppercase to lower case in UNIX ? ( eg shellscript or C-program  to
> perform on multiple files which filename all in Upper-case ).

> Thank you in advanced.

> Best Regards.
> C.W.Lin


 
 
 

Change Upper case filename to lower case filename

Post by Jim Denn » Mon, 07 Jul 1997 04:00:00




Quote:> This convert all filenames in a directory from upper- to lower-case:
>    for file in *
>    do
>    mv $file `echo $file |dd conv=lcase 2>/dev/null`
>    done                                          
> Hope this helps.
>   Randy Howard

        One problem with all of these is that the don't address
        the issue of some files being already in lowercase --
        and especially they don't address the problem of name
        collisions.

        Consider if I have:

                a
                A
                bb
                Bb
                cc

        ... as my files.

        Let's create a shell function for easy readability:

                lcase() {
                        echo $(echo "$1" | tr [:upper:]  [:lower:]
                        }

        Now we can use something like:

                for i in ./*[A-Z]* ; do
                        lname=$( lcase "$i" )
                        [ ! -f "$lname" ] && mv "$i" "$lname" \
                                || echo "$i" collides with "$lname" >&2
                        done

        ... this only matches files with at least one uppercase letter,
        it protects against filenames with spaces in them (by soft quoting
        every variable reference) and it reports collisions on standard
        error.  By preceding the glob pattern with "./" I also protect
        against problems with degenerate filenames (those starting with
        "-" that cause some many users so much trouble).

        It still isn't perfect.  It doesn't check for write access
        to the current directory -- and it may have other problems
        that I haven't thought of, yet.  However it does catch the
        most likely problems.  

        The biggest problem with my sample is that it doesn't take
        any parameters.  I could name it "lower.all.names" -- but
        I'd have to work on it a bit to actually handle an arbitrary
        list of parameters in a robust way.  It would probably double
        the length of the script (at least).
--


Starshine Technical Services              http://www.starshine.org


        Key fingerprint =  2524E3FEF0922A84  A27BDEDB38EBB95A

 
 
 

1. Script to Convert Upper Case Filenames to Lower Case

     Can someone suggest to me a few lines of shell script that will
convert filenames in a directory from upper case to lower case.
     Thanks in advance for any comments or suggestions.

                                -- Larry
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


Computer Consultant/Programmer                    716-685-1865-ext 550  Voice

2. something like MSTSC

3. CONVERTING lower-case to upper-case filenames?

4. Verisign certs and apache builds

5. SUMMARY: change filename from upper to lower case?

6. Check for bad pointer

7. change filename from upper to lower case?

8. C compiler supporting 'long double'

9. change lower case word to upper case using sed?

10. Change upper case file names into lower case

11. script to change lower case to upper case

12. upper/lower case filenames question

13. HELP: shell script to change filenames to lower-case?