[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
- <!--x-content-type: text/plain -->
- <!--x-date: Fri Jan 23 18:13:09 2004 -->
- <!--x-from-r13: wprw ng genthf.bet (Xnzrf QS Xbuafba) -->
- <!--x-message-id: [email protected] -->
- <!--x-reference: 1074260393.6435.3.camel@devel --> "http://www.w3.org/TR/html4/loose.dtd">
- <!--x-subject: [ale] Ripping CD's -->
- <li><em>date</em>: Fri Jan 23 18:13:09 2004</li>
- <li><em>from</em>: jcej at tragus.org (James CE Johnson)</li>
- <li><em>in-reply-to</em>: <1074260393.6435.3.camel@devel></li>
- <li><em>references</em>: <1074260393.6435.3.camel@devel></li>
- <li><em>subject</em>: [ale] Ripping CD's</li>
>I have made the decision to convert my huge CD collection to MP3 now
>that I have a DVD burner. My CD's take up too much room and I can just
>store them in my attic. I normally use mp3c but I would still like to
>use it but in script form to create a structure like this on disk:
>
><genre>/<artist>/<album>/<mp3>
>
>Has anyone written scripts that can do this?
>
The attached perl script is a quick hack I did in December to organize
my collection in three different ways: ByAlbum/abum/song.mp3,
ByArtist/artist/album/song.mp3, ByGenre/genre/artist/album/song.mp3. cd
to the top of a directory full of mp3s and let it go to work. It tries
to be clever with symlinks and doesn't always get things right but, hey,
it *is* a quick hack :-)
>Maybe even a perl script
>that can read the information from the mp3 file and place it in those
>directores. Maybe even outmut a
>
>_______________________________________________
>Ale mailing list
>Ale at ale.org
><a rel="nofollow" href="http://www.ale.org/mailman/listinfo/ale">http://www.ale.org/mailman/listinfo/ale</a>
>
>
-------------- next part --------------
#!/usr/bin/perl
# jcej - 12/2003
# A quick script to organize a set of MP3s
# into directories ByArtist, ByAlbum, ByGenre
use File::Basename;
use File::Find;
use File::Path;
use Getopt::Std;
use MP3::Tag;
# Additional genre's not known by MP3::Tag
my $gl = { 141 => "Christian Rock"
};
my %cl = ();
getopts("Vvg", \%cl);
if($cl{g}) {
my $genres = MP3::Tag->genres;
print join(", ", sort @$genres) . "\n";
exit 0;
}
foreach my $catalog ("ByArtist", "ByAlbum", "ByGenre") {
mkpath($catalog, 1, 0755);
}
my $options =
{
wanted => \&catalog,
no_chdir => 1,
};
find($options, @ARGV);
sub catalog {
my $file = $File::Find::name;
return if( ! -f $file || -l $file || $file !~ m/\.mp3$/ );
print "$file\n" if($cl{v} || $cl{V});
my $mp3 = MP3::Tag::->new($file);
return if( ! $mp3 );
my ($song, $track, $artist, $album) = $mp3->autoinfo();
if($cl{V}) {
my @tags = $mp3->get_tags;
foreach my $tagType (@tags) {
my $tag = $mp3->{$tagType};
while ( my ($key, $value) = each %$tag) {
print "$tagType\t$key\t$value\n";
}
}
}
my $genre = $mp3->{ID3V1}->{genre};
if($genre eq '') {
my $genreID = $mp3->{ID3v1}->{genreID};
$genre = $mp3->genres($genreID);
if($genre eq '') {
$genre = $gl->{$genreID};
}
if($genre eq '' || ref($genre)) {
$genre = 'UNKNOWN';
}
}
my $byAlbum = "$album/$song" . "\.mp3";
my $byArtist = "$artist/$byAlbum";
my $byGenre = "$genre/$byArtist";
makeLink($file, "ByArtist/$byArtist");
makeLink($file, "ByAlbum/$byAlbum");
makeLink($file, "ByGenre/$byGenre");
}
sub makeLink {
my($from, $to) = @_;
my $dir = dirname($to);
mkpath($dir, 1, 0755);
my $prefix = calculatePrefix($to);
symlink($prefix . $from, $to);
}
sub calculatePrefix {
my $file = shift;
my $pfx = "";
while(($file = dirname($file)) ne '.') {
$pfx .= "../";
}
return $pfx;
}
</pre>
<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<!--X-Follow-Ups-End-->
<!--X-References-->
<ul><li><strong>References</strong>:
<ul>
<li><strong><a name="00617" href="msg00617.html">[ale] Ripping CD's</a></strong>
<ul><li><em>From:</em> cfowler at outpostsentinel.com (Chris Fowler)</li></ul></li>
</ul></li></ul>
<!--X-References-End-->
<!--X-BotPNI-->
<ul>
<li>Prev by Date:
<strong><a href="msg00962.html">[ale] [OT] securing sensitive data</a></strong>
</li>
<li>Next by Date:
<strong><a href="msg00964.html">[ale] Nokia 3589i DKU-5 Data Cable</a></strong>
</li>
<li>Previous by thread:
<strong><a href="msg00644.html">[ale] Ripping CD's</a></strong>
</li>
<li>Next by thread:
<strong><a href="msg00625.html">[ale] whois question</a></strong>
</li>
<li>Index(es):
<ul>
<li><a href="maillist.html#00963"><strong>Date</strong></a></li>
<li><a href="threads.html#00963"><strong>Thread</strong></a></li>
</ul>
</li>
</ul>
<!--X-BotPNI-End-->
<!--X-User-Footer-->
<!--X-User-Footer-End-->
</body>
</html>