downcasing_files

This is part of The Pile, a partial archive of some open source mailing lists and newsgroups.



Subject: Re: Changing Uppercase files to Lower case files easily?
From: "Mikkel L. Ellertson" <mikkel@execpc.com>
Date: Tue, 04 Apr 2000 17:02:46 -0500


At 04:12 PM 4/4/00 CDT, you wrote:
>Hello,
>
>I was wondering if there was a way to rename files in Linux that are upper 
>case to the same name only in lower case?
>
>I have about 400 files that were renamed to upper case when I FTP'ed them to 
>the server and I need a quick way to make them lower case.
>
>If anyone can offer any help I would appreciate it.
>
>Thanks,
>Kevin
>
Here are a couple of scripts that I came accross that work.

This on does a single file:

# !/bin/bash
#
# Script to convert file names to lower case.
#
mv $1 `echo $1 | tr "[A-Z]" "[a-z]" `

This one does a directory:

# !/bin/bash
#
# Script to convert file names to lower case.
#
for i in *
do
echo $i
mv $i `echo $i | tr "[A-Z]" "[a-z]" `
done

Both could use some inprovment to check if the lowercase name alread
exists...

===


Subject: Re: Changing Uppercase files to Lower case files easily?
From: "Adam Sleight" <adams@linearcorp.com>
Date: Tue, 04 Apr 2000 15:11:14 -0700


cut and pasted from http://portico.org  I did a search for "lowercase"
 
There is a problem when you migrate web pages from NT to Apache: The filenames
are in a wide range of letter cases. Example: "hello.gif"
can be "HeLlo.GIF" on an NT server. 

Your apache can't show this gif if it isn't exactly named "HeLlo.GIF". The first
thing to do in order to solve it is convert all filenames to
lowercases. The following bash script makes it easy. Only copy and paste it onto
a file named "minus" and give execute permisions. Make
the script available system-wide and execute it in every dir that you want to
convert. 

      #!/bin/sh
      export name=""                                                                                                 
      export namelow=""                                                                                              
                                                                                                                     
      ls > dirtmp.txt                                                                                                
      cat dirtmp.txt|while read name                                                                                 
      do                                                                                                             
              namelow=`echo $name|tr A-Z a-z`                                                                        
              if [ "$name" != "$namelow" ]                                                                           
              then                                                                                                   
                      echo "Renaming $name to $namelow"                                                              
                      mv $name $namelow                                                                              
              fi                                                                                                     
      done                                                                                                           
      rm dirtmp.txt

===

Subject: Re: Changing Uppercase files to Lower case files easily?
From: "Adam Sleight" <adams@linearcorp.com>
Date: Tue, 04 Apr 2000 15:19:42 -0700


http://www.freshmeat.net/appindex/2000/01/26/948918095.html

try this program called CHCASE it might be just a tad easier to use.

chcase is a Perl script that renames files. You can change filenames to either
all upper or all lower case, or use Perl expressions to operate on the
filenames. Some features/options include support for special characters,
recursing through subdirectories, overwriting existing files, specifying
multiple file masks, and operating on filenames with Perl expressions like s///
and tr///.

===

Subject: Re: Changing Uppercase files to Lower case files easily?
From: Hal Burgiss <hburgiss@bellsouth.net>
Date: Tue, 4 Apr 2000 18:15:43 -0400


On Tue, Apr 04, 2000 at 04:12:28PM -0500, K Old wrote:
> I was wondering if there was a way to rename files in Linux that are
> upper case to the same name only in lower case?
> 
> I have about 400 files that were renamed to upper case when I FTP'ed
> them to the server and I need a quick way to make them lower case.



 #!/bin/sh
 # 
 ## -------- convert upper to lower case ---------

 ls * | while read f
  do
    if [ -f $f ]; then
      if [ "$f" != "`echo \"$f\" | tr A-Z a-z`" ]; then 
       #Note that 'This' will overwrite 'this'!
       mv -iv "$f" "`echo \"$f\" | tr A-Z a-z`"
      fi
    fi
  done

 #--- eof

===


the rest of The Pile (a partial mailing list archive)

doom@kzsu.stanford.edu