#!/usr/bin/perl -w
use strict;

# Rename files as defined within this script (in @files)

# moore4e_ch02_fig_02_1.jpg
# ->
# fig_ch2_5.jpg

# get all filenames
my @files = <Larose_3E_fig_UNF*.jpg>;
foreach my $file (@files) {
        if ((my $newfile = $file) =~ s/Larose_3E_fig_UNF_Answers_0?(\d+)_0?(\d+)\.jpg/ans_ch$1_$2.jpg/i) {
                print STDERR  "$file ===> $newfile\n";
                rename $file, lc $newfile;
        }
}