Created
March 11, 2015 19:41
-
-
Save Caaz/cc97da017be57a7b3010 to your computer and use it in GitHub Desktop.
Manual media organization.
This file contains hidden or 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 warnings; | |
use strict; | |
use File::Copy; | |
my ($resolution,$series,$episodePad,$seasonPad); | |
input("Resolution",\$resolution,0); | |
input("Series title",\$series,0); | |
input("Episode Padding",\$episodePad,2); | |
input("Season Padding",\$seasonPad,2); | |
my @files = <"./*$series*">; | |
for(@files) { | |
my ($skip,$episode,$season,$title,$extension); | |
input("$_\nModify [Y/n]]",\$skip,0); | |
next if($skip); | |
input("Season",\$season,1); | |
input("Episode",\$episode,1); | |
input("Title",\$title,0); | |
$episode = '0'.$episode while((split //, $episode) < $episodePad); | |
$season = '0'.$season while((split //, $season) < $seasonPad); | |
($extension = $_) =~ s/.*(\.[^\.]+?)$/$1/; | |
move($_,"$series ($resolution) [$season"."x$episode]".(($title)?" $title":'').$extension); | |
} | |
sub input { | |
my ($message,$ref,$default) = splice @_,0,3; | |
print "$message: "; | |
$$ref = <STDIN>; | |
chomp($$ref); | |
$$ref = $default if((!length $$ref) && (length $default)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment