On Tue, Apr 10, 2001 at 05:18:24PM +0100 or so it is rumoured hereabouts,
Fergal Moran thought:
> > Assuming you want to rename the directories as well as the files:
> >
> > find /path/to/folder -print | while read x ; do
> > mv $x $(echo $x | tr 'A-Z' 'a-z')
> > done
> Cheers Colm
> That almost worked - it did everything in the root folder and one directory
> deep - but did not work any deeper than that - while it was running there
> were a load of messages like
>> mv: cannot stat `/home/www/docs/oracle/server.815/A58231/CH2A.GIF': No such
> file or directory
I'd be inclined to think that the directory "A58231" has been mv'ed to
"a58231" _after_ "CH2A.GIF" has been *found* but _before_ it gets mv'ed so
the path is no longer there.
To avoid that, you'd need to do some kind of recursive directory suck
where you descend th structure to the end of a branch, mv everything in
there, go up one level, repeat for each leaf directory there before mv'ing
the contents of that directory in turn. I had to do something of that
nature for my MP3 indexing script (a nice little something that will index
all the mp3's in a branch with individual indexes for each directory plus
group indexes in the directories above. It may be available from my
webpage (www.geocities.com/~conor_daly) but if not, it will be some day.)
Something like the following should do it:
#######################
#!/bin/bash
for i in `find -name \* -maxdepth 1 -type d | xargs`; do
cd $i
$0
cd ..
done
for i in `find -name \* -maxdepth 1 | xargs`; do
#whatever the clever mv | tr command was goes here
done
#######################
That looks like the thing. It will descend a directory structure, node by
node and only when it reaches a leaf directory will it start renaming.
It'll then rename everything in the current directory, go up one directory
and repeat for any other directories in that dir before renaming everything
in the then current directory.
Conor
--
Conor Daly <conor.daly at oceanfree.net>
Domestic Sysadmin :-)
---------------------
Faenor.cod.ie
9:32pm up 42 days, 7:07, 0 users, load average: 0.00, 0.00, 0.00
Hobbiton.cod.ie
8:49pm up 42 days, 5:59, 1 user, load average: 0.00, 0.04, 0.02
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!