Created
March 13, 2014 07:58
-
-
Save blmarket/9523678 to your computer and use it in GitHub Desktop.
동영상 - 자막 file name mapper
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
| use Data::Dumper; | |
| use Archive::Zip qw( :ERROR_CODES :CONSTANTS ); | |
| $_ = `ls`; | |
| @_ = split /\n/; | |
| @anis = grep /\.mkv$/, @_; | |
| @zips = grep /\.zip$/, @_; | |
| # print Dumper(@anis); | |
| # print Dumper(@zips); | |
| for(my $i=0;$i<=$#zips;$i++) { | |
| $subname = $anis[$i]; | |
| $subname =~ s/\.[^.]*$//; | |
| choosefile($zips[$i], $subname); | |
| } | |
| sub choosefile { | |
| ($zip_name, $subname) = @_; | |
| my $zip = Archive::Zip->new($zip_name); | |
| my @names = $zip->memberNames; | |
| $name = pick_name(\@names); | |
| my ($ext) = $name =~ /(\.[^.]+)$/; | |
| $subname .= $ext; | |
| print $zip_name." ".$name." ".$subname."\n"; | |
| $zip->extractMemberWithoutPaths($name, $subname); | |
| } | |
| sub pick_name { | |
| $_ = shift; | |
| @names = @$_; | |
| return $names[0] if ($#names == 0); | |
| for(my $i=0;$i<=$#names;$i++) { | |
| print "$i $names[$i]\n"; | |
| } | |
| my $pick = 1; | |
| return $names[$pick]; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment