- To: SLug Users <slug@xxxxxxxxxxx>
- Subject: Re: [SLUG] Looking for lazy way out
- From: Gavin Carr <gavin@xxxxxxxxxxxxxxxxx>
- Date: Thu, 23 Jun 2005 08:58:23 +1000
- Organisation: Open Fusion
- User-agent: Mutt/1.4.1i
On Wed, Jun 22, 2005 at 04:56:13PM +1000, Gavin Carr wrote:
> On Wed, Jun 22, 2005 at 04:33:53PM +1000, Simon wrote:
> > I have uploaded a web based CD to our Moodle setup, but all the links
> > are broken. In true sloppy MS style most of the filenames are in
> > uppercase whereas the html files refer to them in lower case. The
> > underlying webserver is Apache, (thought mod-speling might help from
> > some reading but it is already installed). I am looking for the lazy way
> > out of going through and editing all the links in the html files or
> > renaming all the disc files, is there a solution? NB there are hundreds
> > of files and corresponding links :-(
>
> Since laziness is one of the cardinal virtues of the perl-hacker, try:
>
> perl -MFile::Find -e 'find sub { rename $_, lc $_ if -f $_ && $_ =~ m/\.html?$/i }, "."'
>
> from the top of your cd directory tree. This will lowercase all file names
> ending in .htm, .html, .HTML, .HTM, etc., so be careful that's exactly
> what you want!
BTW, if you're familiar with find(1), you can do the same thing with that:
find . -type f -iregex '\..*html?$' -print
to check the file list, and then:
find . -type f -iregex '\..*html?$' -print0 | perl -n -0 -e 'rename $_, lc $_'
to do the renames. Note those '0's are zeros, not letter 'O's.
Cheers,
Gavin