It is currently Mon, 27 Jun 2022 11:37:07 GMT



 
Author Message
 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
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Larry James                                                lja...@apollo3.com
Apollo III Communications                           72667.3...@compuserve.com
Computer Consultant/Programmer                    716-685-1865-ext 550  Voice



 Wed, 28 Aug 1996 06:20:12 GMT   
 Script to Convert Upper Case Filenames to Lower Case

The best solution to this very FAQ is to get the freeware util mmv,
which handles this as well as most other "I can do it in DOS, why can't
I do it in Unix?" type renaming questions.

************************************************************************
Our buggy newsreader limits
the length of .signature files
to 4 lines, but I have figured out
a way to have as many lines as

        - p...@quads.uchicago.edu, who is still costing the net
          hundreds, if not thousands, of dollars, every time he posts -
************************************************************************
rwvpf wpnrrj ibf ijrfer



 Thu, 29 Aug 1996 01:58:47 GMT   
 Script to Convert Upper Case Filenames to Lower Case

Here's a script I use to do this.

#!/bin/csh -f
##################################################################
# Convert specified filenames (not contents) to lowercase.
#
# 02MAR92 Tom Parker, SCD Consulting Office.
##################################################################

# Initialize
    set cmd = `basename $0`
    if ($#argv == 0) then
       echo "Usage: $cmd <file(s)>    # Converts filenames to lowercase"
       exit 1
    endif
    @ n = 0

# Lowercase and rename each specified file.
    foreach orig($*)
       set new = `echo $orig | tr '[A-Z]' '[a-z]'`
       if ($new == $orig) then
          # Already lowercase, so nothing to do.
       else if (-e $new) then
          echo "${cmd}: Can't rename $orig because $new already exists."
       else
          mv $orig $new
          if ($status == 0) then
            echo "${cmd}: Renamed $orig to $new"
            @ n++
          endif
       endif
    end

# Feedback
    echo " "
    echo "$n filenames were converted to lowercase."
    exit

--
+--------------------------------------------------------------------+
| Tom Parker             |  National Center for Atmospheric Research |
| tpar...@ncar.ucar.edu  |  (303) 497-1227                           |
+--------------------------------------------------------------------+



 Thu, 29 Aug 1996 04:26:05 GMT   
 Script to Convert Upper Case Filenames to Lower Case
In <2lqqqs$...@apollo3.com> lja...@apollo3.com (Larry James) writes:

:     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.
:
This appears so frequently it out to be in the FAQ :-).

A perl solution could be:

#!/usr/local/bin/perl

for $oldname (@ARGV) {
        ($newname = $oldname) =~ tr/A-Z/a-z/;
        next if $newname eq $oldname;   # no change necessary
        if (stat($newname)) {                   # check for duplicate
                printf STDERR "Duplicate %s\n", $newname;
                next;
        }
        rename($oldname, $newname);
exit(0);
__END__

There are lots of other ways to accomplish this, but this is
probably one of the faster methods.

Bill
--
INTERNET:  b...@Celestial.COM   Bill Campbell; Celestial Software
UUCP:   ...!thebes!camco!bill   8545 SE 68th Street
                   camco!bill   Mercer Island, WA 98040; (206) 947-5591
SPEED COSTS MONEY -- HOW FAST DO YOU WANT TO GO?



 Thu, 29 Aug 1996 09:11:32 GMT   
 Script to Convert Upper Case Filenames to Lower Case

Gee, you're stubborn. I already told you that Bob Stockler posted a
terrific set of solutions to that very question a few days ago in
CompuServe's SCOForum, and here you are asking all over again.

1) use tr
2) use awk
3) use ksh

As a recent user of Unix, have you ever so much as browsed through the man
pages?  Have you worked through the examples in any one of a dozen
reasonably good Unix primers that now exist, starting with K&P?
--
Jean-Pierre Radley   j...@jpr.com     XC custodian    Sysop, CompuServe SCOForum



 Thu, 29 Aug 1996 14:35:37 GMT   
 Script to Convert Upper Case Filenames to Lower Case

Let's see, something like this should work:

#!/bin/sh

for filename in *
do
        newname=`echo $filename | tr 'A-Z' 'a-z'`
        if [ ! -f $newname ]
        then
                mv $filename $newname
        else
                echo $newname already exists
        fi
done
#end of script

t.



 Fri, 30 Aug 1996 05:17:48 GMT   
 Script to Convert Upper Case Filenames to Lower Case
In <2ltp84$...@camco.celestial.com> b...@camco.celestial.com (Bill

Suppose filenames are:

  Changes  Install  AUTOEXEC.BAT  CONFIG.SYS  MAIN.C  COPY.C

and the user types 'campbell *' where campbell is the name of the above
script.  What conversion do you think he wants?  What do you think he
gets?
--
Rahul Dhesi <dh...@rahul.net>
also:  dh...@cirrus.com



 Fri, 30 Aug 1996 07:04:22 GMT   
 Script to Convert Upper Case Filenames to Lower Case
In <2lqqqs$...@apollo3.com> lja...@apollo3.com (Larry James) writes:

#! /bin/sh
ls | while read i
do
  mv $i `echo $i | tr '[A-Z]' '[a-z]'`
done
--
Max Heffler, Senior Systems Engineer         office: m...@sysdev.com
System Development, Inc.                     home: m...@texsys.com
10500 Westoffice #100                        phone: (713) 266-5667
Houston, Texas  77042                        fax:   (713) 974-4911



 Sat, 31 Aug 1996 02:53:42 GMT   
 
   [ 8 post ] 

Similar Threads

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

2. Change Upper case filename to lower case filename

3. command to convert upper case to lower case in file names

4. Converting from lower case to upper case using sed

5. Script to convert upper case filenames to lowercase

6. upper case vs lower case account names


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software