#!/usr/bin/perl

$dir = "./$ARGV[0]";
$extention = $ARGV[1];
$number = 1;

opendir(DIR,"$dir") or die "could not open $dir: $!";
while ($_=readdir(DIR)){
    if ($_ =~ /.$extention$/ ){
    print "\t$number\t$_\n";
    system "nkf -ed $dir/$_ > $dir/converted";
    system "rm $dir/$_";
    system "mv $dir/converted $dir/$_";
    $number ++;
    }
}

closedir DIR;

exit;
