(?) The Answer Gang (!)
By Jim Dennis, Ben Okopnik, Dan Wilder, Breen, Chris, and... (meet the Gang) ... the Editors of Linux Gazette... and You!

We have guidelines for asking and answering questions. Linux questions only, please.
We make no guarantees about answers, but you can be anonymous on request.
See also: The Answer Gang's Knowledge Base and the LG Search Engine

(!) building MP3 playlists

From Ben Okopnik

Answered By: Thomas Adam, Heather Stern

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.

See attached mp3lists.bash.txt

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.

(!) [Thomas] Excellent. Assuming you have no ordering preference per se:
find /my/dir/with/songs/in -iname '*.mp3' -type f -maxdepth 1 | xargs
mpg321 --list -
Will do just as well :)

(!) '*.mp3' <-- Your DOS habits are showing, Thomas. :)

(!) [Thomas] Hahahahahaha :)

(!) What's an "mpg321"? I'm familiar with "mpg123", but...

(!) [Thomas]
[n6tadam@laptop n6tadam]$ apt-cache show mpg321

Description: A Free command-line mp3 player, compatible with mpg123
 mpg321 is a clone of the popular mpg123 command-line mp3 player. It should
 function as a drop-in replacement for mpg123 in many cases. While some of
 the functionality of mpg123 is not yet implemented, mpg321 should function
 properly in most cases for most people, such as for frontends such as

(!) Ah. I thought it might have been a mispeeling.

Also, this invocation of "find" would get only the top-level MP3s - none of the ones in the album subdirectories.

(!) [Thomas] Yes, but then I assume that most of don't have such a highly-ordered set of files.

(!) How do you figure "most of" organize their MP3s, then? I can't quite see naming each file something like

Ella Fitzgerald - Ella & Friends 01. Ain't Nobody's Business But My Own.mp3 Ella Fitzgerald - Ella & Friends 02. Baby, It's Cold Outside.mp3

etc. Besides, most ripper programs produce a directory structure in the first place.

(!) [Thomas] Do they? I admit I have no idea of that -- I prefer CD's.

(!) [Nod] All the spaces are a bit annoying, which is why you don't generally want to be typing all that stuff out. Fortunately, we have - tadaa! - playlists.

(!) [Thomas] I would be rather annoyed at all the spaces in the filename though. Then again my file organisation is a mess. You should see my desk.

(!) I can't carry all my CDs with me. :( I'd be willing to bet that 256kB MP3s don't sound any different from CDs even to your musically-trained ears, even with really good quality headphones.

(!) [Heather] Maybe Ogg Vorbis format is worth a listen, for people with picky ears.
They sound ever so slightly different to me. **sigh** I miss analog equalizers. They really hit the sweet spot.

(!) Are these 256kBs, or the standard "anything goes" types? I've never administered one myself, but AIUI, it's rare for anyone to pass the actual taste test.

(!) [Heather] abcde and our household became good friends awhile back - around the time the CD carousel was getting rowdy about giving us our discs back.

(!) I haven't tried it, but it looks pretty good. These days, I mostly stick with John the Ripper - nice and simple.

(!) [Thomas] That being the case then, just change "-maxdepth 1" to "maxdepth 2"
I dunno, these brainiac types with their good ideas....
Which would give you a single playlist with all the songs in it instead of individual ones, missing the whole point of the exercise. :)
(!) [Thomas] Nah, it would still play the songs :)

(!) So would "find /my/dir|mpg123 -@ -", but that wasn't the point. If I want to listen to just the ACDC "Back in Black" album, your example won't be of much use unless you rewrite it every time - including all those annoying spaces in the album name.

(!) [Heather] Isn't that what tab completion is for...

(!) Not for those of us who would find retyping the entire command line every single time a pointless exercise - or like looking at the playlists to figure out what kind of music feels right next.

(!) [Heather] And the final tidbit, it's always nice to make symlink farms of stuff you feel fits a nice mood. After you do that, you're not limited to "albums" in the order your plastic carries them.

This page edited and maintained by the Editors of Linux Gazette
Copyright © its authors, 2004
Published in issue 100 of Linux Gazette March 2004
HTML script maintained by Heather Stern of Starshine Technical Services, http://www.starshine.org/

[ Table Of Contents ][ Answer Guy Current Index ] greetings   Meet the Gang   1   2   3   4   5   6   7 [ Index of Past Answers ]