Created
December 6, 2009 12:57
-
-
Save klette/250206 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use utf8; | |
open(COMMANDS, '>>cmds.sh'); | |
for my $movie (<./*>){ | |
print "Analyzing $movie..\n"; | |
for my $dir (<./$movie/*>){ | |
if ($dir =~ m/.*([Cc][Dd][1-5]).*/){ | |
print "\tFound $1\n"; | |
my $cd = $1; | |
my $multipart = 0; | |
for my $rar (<./$movie/$cd/*.rar>){ | |
next if $multipart; | |
if ($rar =~ m/.*part(\d+).rar/){ | |
print "\t\tFound part-rars.. ($rar)\n"; | |
$multipart = 1; | |
my $filename = `unrar lb $rar` ; | |
chomp($filename); | |
print "\t\tExtracting $cd..\n"; | |
print COMMANDS "unrar x $rar\n"; | |
print "Moving $filename to $movie/$cd.avi\n"; | |
print COMMANDS "mv $filename $movie/$cd.avi\n"; | |
print COMMANDS "rm -rf $movie/$cd\n"; | |
next; | |
} else { | |
print "\t\tFound numeric rars.. ($rar)\n"; | |
my $filename = `unrar lb $rar` ; | |
chomp($filename); | |
print "\t\tExtracting $cd..\n"; | |
print COMMANDS "unrar x $rar\n"; | |
print COMMANDS "mv $filename $movie/$cd.avi\n"; | |
print COMMANDS "rm -rf $movie/$cd\n"; | |
print "\t\tMoving $filename to $movie/$cd.avi\n"; | |
next; | |
} | |
} | |
} | |
} | |
my $multipart = 0; | |
for my $rar (<$movie/*.rar>){ | |
next if $multipart; | |
if ($rar =~ m/.*part(\d+).rar/){ | |
print "\t\tFound part-rars.. ($rar)\n"; | |
$multipart = 1; | |
my $filename = `unrar lb $rar` ; | |
chomp($filename); | |
print COMMANDS "unrar x $rar\n"; | |
print "\t\tMoving $filename to $movie/" . lc($movie) . ".avi\n"; | |
print COMMANDS "rm -rf $movie/*.r*\n"; | |
print COMMANDS "mv $filename $movie/" . lc($movie) . ".avi\n"; | |
last; | |
} else { | |
print "\t\tFound numeric rars.. ($rar)\n"; | |
my $filename = `unrar lb $rar` ; | |
chomp($filename); | |
print COMMANDS "unrar x $rar\n"; | |
print "\t\tMoving $filename to $movie/" . lc(substr($movie,2)) . ".avi\n"; | |
print COMMANDS "rm -rf $movie/*.r*\n"; | |
print COMMANDS "mv $filename $movie/" . lc(substr($movie,2)) . ".avi\n"; | |
last; | |
} | |
} | |
} | |
close(COMMANDS); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment