summaryrefslogtreecommitdiff
path: root/bin/incoming/groupfiles.pl
diff options
context:
space:
mode:
Diffstat (limited to 'bin/incoming/groupfiles.pl')
-rwxr-xr-xbin/incoming/groupfiles.pl62
1 files changed, 62 insertions, 0 deletions
diff --git a/bin/incoming/groupfiles.pl b/bin/incoming/groupfiles.pl
new file mode 100755
index 0000000..62b6fa5
--- /dev/null
+++ b/bin/incoming/groupfiles.pl
@@ -0,0 +1,62 @@
+#!/usr/bin/perl
+# - display counts of mixed-up album mp3s in the current directory
+# - add prefixes to the filenames
+use MP3::Tag;
+my @t;
+#my $TAG = shift @ARGV || die "NO TAG SPECIFIED";
+my $BIN_MV = "/bin/mv";
+opendir D, "." or die $!;
+while (my $f = readdir D)
+ {
+ push (@t, $f) if $f =~ /mp3$/
+ }
+closedir D;
+my $albs = {};
+foreach my $t (sort @t)
+ {
+ my $a;
+ my $mp3 = MP3::Tag->new($t);
+ $mp3->get_tags();
+
+ my ($title, $track, $artist, $album, $comment, $year, $genre) = $mp3->autoinfo();
+
+$track = sprintf "%02d", $track;
+$artist =~ /^(..?.?)/;
+my $art = lc $1;
+$album =~ /^(The )?(..?.?)/;
+my $alb = lc $2;
+
+# my $newf = "$art-$alb-$track $title.mp3";
+my $newf = "$track $title.mp3";
+$newf =~ s/[^-A-Za-z0-9 _\.]//g;
+print $newf."\n";
+
+system($BIN_MV, $t, $newf);
+
+ $albs->{$art} ||= {};
+ $albs->{$art}->{$alb} ||= [];
+ $albs->{$art}->{$alb} = 1;
+
+
+# if (! $a) { print STDERR "TAGLESS: $t\n"; next; }
+# my $id = $mp3->track0(2);
+# my $newt = $TAG. '-' . $id . '-' . $t;
+# print "$newt\n";
+# system($BIN_MV, $t, $newt);
+# $albs->{$a} ||= [];
+# push @{ $albs->{$a} }, $t;
+ }
+
+map {print $_, " => ", join ",", keys(%{$albs->{$_}}), "\n" } keys %$albs;
+#my @keyz = qw[ZENC ZEND ZENE ZENF];
+#my $q = 0;
+#foreach my $a (sort keys %$albs)
+# {
+# my $count = scalar @{ $albs->{$a} };
+## print "$keyz[$q] : $a : $count\n";
+# foreach my $f (@{ $albs->{$a} })
+# {
+# # system($BIN_MV, $f, $keyz[$q] . "-" . $f);
+# }
+# $q++;
+# }