#!/usr/bin/perl

if ($#ARGV >= 0) {
  $cmd = "ls " . $ARGV[0] . " |";
}
else {
  $cmd = "ls |";
}

open( READ, $cmd ) || die "couldn't open $cmd: $!\n"; 

while( <READ> ) {
  chomp;
  push @files, $_;
}

for( $i = 0; $i < $#files; $i++ ) {

  $old = $files[$i];
  $img = $files[$i];
  $img =~ m/([^\/]*)\.([^.]*)$/;
  $new = "tun6" . $1 . ".jpg";

  rename $old, $new;
}

close( READ );

