|
发表于 2003-4-30 00:50:55
|
显示全部楼层
use perl to rename it.
Here is the perl script I wrote years ago.
It will firstly ask you in which directory your files are, and secondly ask you the old names' pattern, in your case ".mpga", and then ask you the new names' pattern ".mp3".
After getting these three information, it will replace all the old filename with the new one.
Hope it will be helpful.
#!/usr/bin/perl -w
use strict;
my($dir, $oldpat, $newpat);
print "Directory:";
chomp($dir=<STDIN>);
print "Old pattern:";
chomp($oldpat=<STDIN>);
print "New pattern:";
chomp($newpat=<STDIN>);
opendir(DH, $dir) ||die "Cannot open $dir: $!";
my @files=readdir DH;
close(DH);
my $oldname;
foreach(@files){
$oldname=$_;
s/$oldpat/$newpat/;
next if (-e "$dir/$_");
if (! rename "$dir/$oldname", "$dir/$_"){
warn "Could not rename $oldname to $_: $!";
}else {
print "File $oldname renamed to $_\n";
}
}; |
|