Last active
December 20, 2015 14:29
-
-
Save jbarrett/6147397 to your computer and use it in GitHub Desktop.
Quick and dirty script to rename DVD Rips, supplies the existing filename (minus ext) to IMDB for a suggested title/year. Confirms each action (occasionally IMDB::Film comes back with the wrong title or nothing at all, so full automation would be bad). `yes | rename_movies.pl` if you *really* want to do this.
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/env perl | |
use IMDB::Film; | |
use File::Copy; | |
use autodie; | |
# Rename DVD Rips, with suggestion from IMDB. | |
my $dir = shift || '/media/usb1/vids/Movies'; | |
opendir (my $dh, $dir); | |
for (sort readdir($dh)) { | |
next if (-d "$dir/$_"); | |
my ($fn, $ext) = $_ =~ /(.*)\.([a-zA-Z]+)$/; | |
$fn || next; | |
my $imdb = IMDB::Film->new( crit => $fn ); | |
my $sfn = $imdb->title . " (" . $imdb->year . ").$ext"; | |
print "$_ -> $sfn " . ((-e "$dir/$sfn")? "(overwrite)" : "") . " [y/N]?"; | |
chomp (my $rename = <STDIN>); | |
($rename =~ /^y/i) || next; | |
print "Renaming $_ to $sfn..."; | |
move("$dir/$_", "$dir/$sfn"); | |
print "done\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment