*BSD News Article 83225


Return to BSD News archive

Newsgroups: comp.infosystems.www.servers.unix,comp.unix.bsd.freebsd.misc,comp.unix.programmer,comp.unix.questions
Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!munnari.OZ.AU!news.ecn.uoknor.edu!feed1.news.erols.com!hunter.premier.net!www.nntp.primenet.com!nntp.primenet.com!howland.erols.net!netcom.com!kxr
From: kxr@netcom.com (Keith Rich)
Subject: Re: Help Need a UTIL for Case Sensitive Files.
Message-ID: <kxrE151Do.Ls2@netcom.com>
Organization: Netcom Online Communications Services (408-241-9760 login: guest)
References: <01bbd5d3$54b9d060$86629dcc@big-one>
Date: Tue, 19 Nov 1996 22:05:48 GMT
Lines: 32
Sender: kxr@netcom10.netcom.com
Xref: euryale.cc.adfa.oz.au comp.infosystems.www.servers.unix:22109 comp.unix.bsd.freebsd.misc:31266 comp.unix.programmer:46558 comp.unix.questions:91568

In article <01bbd5d3$54b9d060$86629dcc@big-one> "Erotic Delirium" <kelly@eroticd.com> writes:
>does anyone have a utility that will go through and change filenames &
>directories from uppercase to lower case.  I need to change everything in a
>certian directory including subdirs to lowercase and its about 9000 files.
>(no joke)
>-- 
>Kelly
>

Make a shell script called upp2low containing:

  #!/bin/sh
  dirname=`dirname $1`
  basename=`basename $1`
  basenew=`echo $basename | tr A-Z a-z`
  if test "$basenew" != "$basename"; then
    (cd $dirname ; mv $basename $basenew)
  fi

Then invoke it as follows:

  find dir -depth -exec upp2low {} \;

The -depth will make sure that all sub-directories get renamed before
the upper level directories.  The dirname/basename stuff is changing
only the lowest level name; without that it won't work right.

For a System V Unix (rather than BSD), change "tr A-Z a-z" to:

  tr '[A-Z]' '[a-z]'

Keith