-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
sr-rename
executable file
·39 lines (31 loc) · 952 Bytes
/
sr-rename
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/perl
# vim: ft=perl:fdm=marker:fmr=#<,#>:fen:et:sw=2:
# abstract: a little tool to clean up episodes downloaded from Sveriges Radio.
use strict;
use warnings FATAL => 'all';
use vars qw($VERSION);
use autodie qw(:all);
use utf8;
use open qw(:std :utf8);
my $APP = 'sr-rename';
$VERSION = '0.001';
use MP3::Info;
use File::Copy::Recursive qw(fcopy);
use File::LsColor qw(ls_color);
my @files = @ARGV;
for my $file(@files) {
my $tags = MP3::Info->new($file);
my ($artist, $title, $album, $year) = ($tags->{ARTIST},
$tags->{ALBUM},
$tags->{TITLE},
$tags->{YEAR},
);
my $new_name = sprintf("%s [%s] %s.mp3", $artist, $year, $album);
if(fcopy($file, $new_name)) {
printf "'%s'\n", ls_color($new_name);
unlink($file);
}
else {
warn "$!\n";
}
}