[geeks] Renaming en masse
Jonathan C. Patschke
jp at celestrion.net
Mon Feb 24 15:48:19 CST 2003
I'm in the process of stashing a whole bunch of HTML files from CDs into
a server so that I can stop going nuts looking for documentation. I've
run into a bit of a problem: Some of the CDs (especially the older ones)
don't have Rockridge encoding, so all the filenames are in upper case.
The author assumed that the files would be viewed on a PC using a
case-insensitive filesystem.
What's a good way to recursively rename an entire directory structure?
So far, I've done this:
find . -depth -print > list.txt
grep -v list.txt list.txt > list.new
That gets me a list of the files, removes "list.txt" from the list. At
this point, I'd like to use "for" to iterate over the list of files, but
I can't seem to figure out what regexp would get the job done for me.
This:
for i in `cat list.new`
do mv $i `echo $i | tr '[:upper:]' '[:lower:]'`
won't work because it converts the entire path to lower-case, prior to
making the directories lower-case. If there were a way that I could
apply 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwyz/' to
's/\/[a-zA-Z0-9.-]*$/' on each line of list.new, I think that'd get it,
but I don't know enough sed to do that.
Is there perhaps a simple solution that I'm missing?
--
Jonathan Patschke *) "Microsoft doesent have to be involved in order
Thorndale, TX (* for people to be ignorant morons. It's just a
*) contributing factor." --Bill Bradford
More information about the geeks
mailing list