Nathan Pralle - www.nathanpralle.com
Kickass Phone Rates from 3U
PLACES TO GO:  
Back to Software Print Version
ALLTAG

Scripts.com Freshmeat The Perl Archive HotScripts

#!/usr/bin/perl -w 
use strict;

###############################################################
# ALLTAG - MP3 retagging utility
# Copyleft 2005 - Nathan E. Pralle
#
# DESCRIPTION: 	This utility sets an MP3's ID3 tag as a derivative 
# of the file name.  It expects file names to be in the form:  
# ARTIST - SONGNAME.mp3 
# It can handle full pathnames easily as well.
# 
# SYNTAX:  ls *.mp3 | perl alltag.pl
# I prefer to work up an entire listing of all MP3 files I want 
# to retag and run them through all at once, a la:  
# find | grep \.mp3 | perl alltag.pl
#  
# REQUIRED: You must have id3ed installed on your system to do the
# actual tagging.  (Get it from freshmeat.net)
# 
# CONTACT:  Questions?  Comments? 
#           http://www.nathanpralle.com/contact.html
#################################################################

foreach my $O(){
	print "Processing $O";
	my @values=split(/\//,$O);
	my $filename=pop @values;
	chomp($filename);
	print "Evaluating file: $filename\n";
	$filename=~s/\.mp3//gi;
	if($filename=~/-/){
		my($artist,$songtitle)=split(/\s*-\s*/,$filename);
		if(defined $artist && defined $songtitle){
			print "ID3 tagging $artist - $songtitle\n";
			chomp($O);
			system("/usr/local/bin/id3ed -q -s \"$songtitle\" -n \"$artist\" \"$O\"\n");
		}
	}
}

print "Done with processing.\n";
exit;

This site and all content (C)2002-2008 Nathan E. Pralle (www.nathanpralle.com).