Here's a handy perl script which lets you use perl statements to modify
file names.  It may be the same thing as your rename program or not -
rename is not a standard item in all distributions.

----------------------------------------------------------
#!/usr/local/bin/perl

# rename script examples from lwall:
#       rename 's/\.orig$//' *.orig
#       rename 'y/A-Z/a-z/ unless /^Make/' *
#       rename '$_ .= ".bad"' *.f
#       rename 'print "$_: "; s/foo/bar/ if <stdin> =~ /^y/i' *

$op = shift;
for (@ARGV) {
    $was = $_;
    eval $op;
    die $@ if $@;
    rename($was,$_) unless $was eq $_;
}
----------------------------------------------------------

To do it recursively, you'd combine it with find and xargs:

    find . -print0 | xargs -0 rename 's/\.JPE?G$/.jpg/i'

that will turn .JPG, .jpeg or .JPEG suffixes into .jpg


Andrew



On Wed, 30 Jul 2003, Voytek Eymont wrote:

> Date: Wed, 30 Jul 2003 21:02:29
> From: Voytek Eymont <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: [SLUG] mixED CAse to lower.case ?
>
> what can I use to recursively change file names/extension to all lower case ?
>
> I have some files and/directories like:
>
> I tried rename few times with little effect:
>
> [EMAIL PROTECTED] photos]# rename .JPG *.jpg
> [EMAIL PROTECTED] photos]# ls
> atomfactory1.JPG      makitapage03-s.jpg  makitapage10-s.jpg
> atomfactory2.JPG      makitapage04-s.jpg  makitapage11-s.jpg
> atomfactory3.JPG      makitapage05-s.jpg  makitapage12-450.jpg
> makitapage01-450.jpg  makitapage06-s.jpg  makitapage12-s.jpg
> makitapage01-n.jpg    makitapage07-s.jpg  shopfront.jpg
>
>
>
>
> Voytek Eymont
>

--

No added Sugar.  Not tested on animals.  May contain traces of Nuts.  If
irritation occurs, discontinue use.

-------------------------------------------------------------------
Andrew McNaughton           In Sydney
                            Working on a Product Recommender System
[EMAIL PROTECTED]
Mobile: +61 422 753 792     http://staff.scoop.co.nz/andrew/cv.doc



-- 
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug

Reply via email to