[TAG] 2-cent tip: building MP3 playlists

Ben Okopnik ben at callahans.org
Tue Feb 3 17:33:29 MSK 2004


I have a directory where I keep my MP3s, arranged my artist and album,
plus a few single songs in the top directory itself. What I wanted was
to build playlists for each album (where the name of the playlist would
be the same as that of the album), including one for all the singles;
not a hard task, considering that a playlist is nothing more than a list
of absolute paths to the mp3s to be played - which is exactly what the
"find" command produces when invoked that way.

``
#!/bin/bash
# Created by Ben Okopnik on Fri Jul 25 16:12:04 EDT 2003

ldir=~/MP3_lists	# "Lists" directory
mdir=/usr/local/Music	# Music directory
rm $ldir/*m3u           # Rebuild from scratch

echo -n "Rebuilding"
for n in $mdir/*
do 
	[ -d "$n" ] && find "$n" -type f > "$ldir/${n##*/}.m3u"
	echo -n "."
done

find $mdir -maxdepth 1 -type f > $ldir/unclassified.m3u

echo " Done."
''

Set "ldir" and "mdir", stick the program (I call mine "mp3lists") in a
directory in your path (say, "/usr/local/bin"), and run it whenever you
want to recreate your lists.


* Ben Okopnik * okopnik.freeshell.org * Technical Editor, Linux Gazette *
-*- See the Linux Gazette in its new home: <http://linuxgazette.net/> -*-




More information about the TAG mailing list