*BSD News Article 83321


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!munnari.OZ.AU!news.Hawaii.Edu!ames!enews.sgi.com!news.sgi.com!news.bbnplanet.com!su-news-hub1.bbnplanet.com!www.nntp.primenet.com!nntp.primenet.com!howland.erols.net!news.mathworks.com!uunet!in3.uu.net!not-for-mail
From: Jerry Aguirre <jerry@whowhere.com>
Newsgroups: comp.infosystems.www.servers.unix,comp.unix.bsd.freebsd.misc,comp.unix.programmer,comp.unix.questions
Subject: Re: Help Need a UTIL for Case Sensitive Files.
Date: Wed, 20 Nov 1996 15:35:37 -0800
Organization: WhoWhere?
Lines: 38
Message-ID: <329395C9.2D13@whowhere.com>
References: <01bbd5d3$54b9d060$86629dcc@big-one> <Pine.GSO.3.95.961119211603.5049F-100000@goodguy>
NNTP-Posting-Host: rigel-gt.whowhere.com
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Mailer: Mozilla 3.0 (X11; I; SunOS 5.5 sun4m)
Xref: euryale.cc.adfa.oz.au comp.infosystems.www.servers.unix:22167 comp.unix.bsd.freebsd.misc:31348 comp.unix.programmer:46647 comp.unix.questions:91690

Cal Dunigan wrote:
> 
> On 19 Nov 1996, Erotic Delirium wrote:
> 
> > 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.
> 
> You can use either sed or tr in a set of nested for loops. The

Think pipes, not loops!

How about the following script:

#!/bin/sh
find . -name '*[A-Z]*' -print | head -10 | sed -e 's/^/mv /
h
s/^mv//
y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
H
g
s/\n//
p' | sh

This will do the renames in a single pass.  No problems with numbers of
files in a directory or total number of files.  Calls "mv" once for each
rename though.  For really big jobs you would want something using a
system
call for rename instead of fork/exec of a process, but good enough for a
once off.


			Jerry Aguirre
			Senior Systems Administrator
			WhoWhere?
			2570 West El Camino Real
			Suite 309
			Mountain View, CA 94040