Last active
August 29, 2015 14:25
-
-
Save ericychoi/747c916a62411100a6ef to your computer and use it in GitHub Desktop.
A Perl script that sets mp3 tags based on filename
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
use MP3::Tag; | |
use Encode qw/encode decode/; | |
use Data::Dumper; | |
use strict; | |
use warnings; | |
# run it in the same directory as mp3s | |
# sets mp3v2 tags based on file names (assumes filenames are encoded UTF-8, which should be) | |
# | |
# filename example: 085. 2PM-01-우리집.mp3 | |
# album is hard coded for now. TODO: get this from dir name? | |
my @list = <*.mp3>; | |
my $i = 0; | |
for my $file (@list) { | |
print "processing $file", "\n"; #exit(0) if $i++; | |
my $update_h; | |
$file =~ /^(\d+). (.+)-\d+-(.+).mp3$/; | |
@$update_h{qw(track artist title album)} = ($1, $2, $3, '[멜론] 07월 20일 실시간 Top100'); | |
# print Data::Dumper::Dumper($update_h); | |
map { $update_h->{$_} = decode("UTF-8", $update_h->{$_}) } keys(%$update_h); | |
my $mp3 = MP3::Tag->new($file); | |
$mp3->update_tags($update_h); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment