32 lines
581 B
Perl
32 lines
581 B
Perl
#!/bin/perl
|
|
use File::Copy;
|
|
|
|
opendir (in,".");
|
|
@a=readdir(in);
|
|
close in;
|
|
|
|
foreach (@a) {
|
|
chomp;
|
|
if (-d $_) {
|
|
if ($_ =~ /\([0-9]+\)$/) {
|
|
print "alt: $_\n";
|
|
($new,$no) = $_ =~ /(.*)(\([0-9]+\))$/;
|
|
$new =~ s/\s+$//;
|
|
print "neu: $new\n";
|
|
$alt=$_;
|
|
|
|
opendir (mv,"$alt");
|
|
@b=readdir(mv);
|
|
close mv;
|
|
foreach (@b) {
|
|
next if (-d $_);
|
|
($oldfile,$ext) = $_ =~/(.*)\.(.*)$/;
|
|
$newfile=$oldfile.$no.".".$ext;
|
|
print "mv '$alt\\$_' '$new\\$newfile'\n";
|
|
move ("$alt\\$_", "$new\\$newfile");
|
|
}
|
|
}
|
|
}
|
|
print "\n";
|
|
}
|