[PLUG] Renaming photo files

David Fleck david.fleck at mchsi.com
Mon Sep 22 11:10:02 UTC 2003


On Mon, 22 Sep 2003, Rogan Creswick wrote:
> Someone correct me if I'm wrong, but I believe rename takes a perl
> reg. to perform the substitution.  This should work (although I can't
> test it at the moment):

I think you're wrong.  Doesn't work on the RedHat 9.0 machine I just
tried; rename is a binary file.  You may be thinking of a small,
commonly-used perl script that behaves the way that you mention:

#!/usr/bin/perl -w
# rename - Larry's filename fixer
$op = shift or die "Usage: rename expr [files]\n";
chomp(@ARGV = <STDIN>) unless @ARGV;
for (@ARGV) {
    $was = $_;
    eval $op;
    die $@ if $@;
    rename($was,$_) unless $was eq $_;
}
#-----------------------------
#% rename 's/\.orig$//'  *.orig
#% rename 'tr/A-Z/a-z/ unless /^Make/'  *
#% rename '$_ .= ".bad"'  *.f
#% rename 'print "$_: "; s/foo/bar/ if <STDIN> =~ /^y/i'  *
#% find /tmp -name '*~' -print | rename 's/^(.+)~$/.#$1/'
#-----------------------------
#% rename 'use locale; $_ = lc($_) unless /^Make/' *
#-----------------------------


 --
David Fleck
david.fleck at mchsi.com





More information about the PLUG mailing list