#!/usr/bin/perl -w
#Kim Briggs 2004-10
#
# RENAME files with new TEXT NAME having NUMBERS FIRST.
#
# Allows for adding 1-off names and keeping order.
# No photo alterations.
#
#Initialize counter
$i = 1;
#Get the new base name of photos
print "Base name of photos (no ext): ";
chomp($basename = <>);
#Load all jpgs into an array. Remove trailing line feed.
@pix = `ls *.JPG *.jpg`;
foreach $pix (@pix) {
chomp $pix;
if ($i < 10)
{$newname = "0".$i."-".$basename.".jpg";}
elsif (($i >= 10) && ($i < 100))
{$newname = $i."-".$basename.".jpg";}
else {warn "Number of files out of range.";}
#Use system command to rename file.
system 'mv', $pix, $newname;
$i = $i+1
}