64 lines
1.8 KiB
Plaintext
64 lines
1.8 KiB
Plaintext
|
#!/usr/bin/perl
|
||
|
#
|
||
|
# All of MP3 to Sane
|
||
|
# usage: all2sane <files>
|
||
|
#
|
||
|
# Renames the files to a sane format, then calls vcfromfilename
|
||
|
# to set the vorbis comments
|
||
|
#
|
||
|
# Requires vcfromfilename, fixname
|
||
|
#
|
||
|
# Changelog:
|
||
|
# 0.2: version now aligned with ds-audiotools
|
||
|
# 0.1.2: automated artist determination
|
||
|
# 0.1.1: added VERSION variable
|
||
|
# added call to fixname
|
||
|
# 0.1: initial implementation
|
||
|
|
||
|
$VERSION = "0.2";
|
||
|
$HELP_MSG = "All of MP3 to Sane v$VERSION\n\tusage: all2sane <files>\n";
|
||
|
|
||
|
$END_CHUNK = '_\d{3}_ogg_.*\.ogg$'; # match the unwanted end of the string
|
||
|
$DESIRED_END = '.ogg'; # replace the end chunk with this
|
||
|
$ALLOFMP3_FORMAT = '^\d{2}_?-_?.*' . $END_CHUNK;
|
||
|
|
||
|
if ($#ARGV < 0) { die $HELP_MSG; }
|
||
|
foreach (@ARGV)
|
||
|
{
|
||
|
if (/^(--help)|(-h)$/) { die $HELP_MSG; }
|
||
|
}
|
||
|
|
||
|
$artist = `cd .. && pwd`;
|
||
|
$artist =~ s/^.*\///;
|
||
|
|
||
|
foreach (@ARGV)
|
||
|
{
|
||
|
next unless /$ALLOFMP3_FORMAT/;
|
||
|
my $old_name = $_;
|
||
|
|
||
|
$_ = $artist . '-' . $_; # prepend artist
|
||
|
s/_-_/-/g; # clear up the _ problem
|
||
|
s/$END_CHUNK/$DESIRED_END/;
|
||
|
|
||
|
system('mv', $old_name, $_);
|
||
|
system('fixname', $_);
|
||
|
system('vcfromfilename', $_);
|
||
|
}
|
||
|
|
||
|
|
||
|
# Copyright (c) 2005 John Wiggins
|
||
|
#
|
||
|
# This program is free software; you can redistribute it and/or modify
|
||
|
# it under the terms of the GNU General Public License as published by
|
||
|
# the Free Software Foundation; either version 2 of the License, or
|
||
|
# (at your option) any later version.
|
||
|
#
|
||
|
# This program is distributed in the hope that it will be useful,
|
||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
# GNU General Public License for more details.
|
||
|
#
|
||
|
# You should have received a copy of the GNU General Public License
|
||
|
# along with this program; if not, write to the Free Software
|
||
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|