rendered paste body#!/usr/bin/perl
use strict;
use File::Find;
use Data::Dumper;
my %hash;
my @remove_files;
opendir DIR, "./" or die "Bad dir : $!\n";
my @directories = readdir(*DIR);
my @fixed_dirs;
map { push ( @fixed_dirs, $_ ) if ( $_ !~ /^\.+$/) && -d $_ } @directories;
print "FIXED: ",join("\n",@fixed_dirs),"\n";
my %options = ( preprocess => sub { sort { reverse $a cmp reverse $b } @_ } );
find( \%options , @fixed_dirs);
find(\&wanted, @fixed_dirs) ;
close DIR;
print "Next\n";
print Dumper(%hash);
sub wanted {
if ( /(\.part\d\d)*\.([ra\d]{3})$/ ) {
if ( ! $hash{$File::Find::dir}{'done'} ) {
my $origfile = $_;
$_ =~ s/(\.part\d\d)*\.([ra\d]{3})|(\d{3})$//;
my $shortname = $_;
if ( ! map { $shortname eq $_ } @{$hash{$File::Find::dir}{'done'}} ) {
push ( @{$hash{$File::Find::dir}{'extracted'}}, $origfile);
print "unrar e -o- $origfile\n";
push ( @{$hash{$File::Find::dir}{'done'}}, $shortname);
}
}
}
}