Skip to content

Instantly share code, notes, and snippets.

@blmarket
Created March 13, 2014 07:58
Show Gist options
  • Select an option

  • Save blmarket/9523678 to your computer and use it in GitHub Desktop.

Select an option

Save blmarket/9523678 to your computer and use it in GitHub Desktop.
동영상 - 자막 file name mapper
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