#!/usr/bin/perl -w
use strict;
# renames files without suffix to having 'a' as suffix: 123.jpg -> 123a.jpg

open (FILELIST, "ls *[^a-z]_*|") || die "can't get list of non-suffixed files";
while (<FILELIST>) {
     my $filename = $_;
     my @filepart = split (/_/);
     my $newname =  $filepart[0] . "a_" . $filepart[1];
     chomp ($filename);
     chomp ($newname);
     print "$filename -> $newname\n";
     rename ($filename,"$newname") || die "Can't rename: $!";
}
close (FILELIST);
exit (0);

