init III
This commit is contained in:
31
Perl rename dirs and merge/rendir.pl
Normal file
31
Perl rename dirs and merge/rendir.pl
Normal file
@@ -0,0 +1,31 @@
|
||||
#!/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";
|
||||
}
|
||||
Reference in New Issue
Block a user