Hi Scott.
Scott R. Godin wrote:
> John W. Krahn wrote:
>
> > chomp;
> > if ( /(.*)\.BMP/ ) {
> > print "processing image $_ ..\n";
> > system( 'mv', $_, "$1.bmp" ) == 0 or die "system 'mv $_'
> > failed: $?";
> > }
>
> next unless /(.*)\.BMP$/;#anchor it to the end of the string!
> print "processing image file: $_\n";
>
> #rename will clobber existing files, so check first!
> warn "File exists!: $1.bmp. skipping...\n" && next
> if -f "$1.bmp";
>
> # use perl rather than spawning external processes!
> rename( $_, "$1.bmp" ) or die "unable to rename file $_: $!";
There's a big [SNIP] here from the end of John's post:
John W. Krahn wrote:
> However, you could write the whole thing in perl and avoid the pipes
> and system().
>
> #!/usr/bin/perl
> use warnings;
> use strict;
> use File::Find;
> use File::Copy;
>
> find( sub {
> return unless -f and /^(.+)\.BMP$/s;
> move( $_, "$1.bmp" ) or warn "Cannot move $_: $!";
> }, '.' );
>
> __END__
Rob
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]