#!/usr/bin/perl my %listing; open(LS, "ls ???_*.jpg|"); foreach $file () { chomp($file); $file =~ /img_(\d{4})\.jpg/; my $new_num = ($1 + 1300); $listing{$file} = "2005_" . $new_num . ".jpg"; } while (($old, $new) = each(%listing)) { print "$old => $new"; print "\n"; system("mv ./$old ./$new"); } close(LS);