[CLUE-Tech] more on recursive .mp3 playing

Dave Price davep at kinaole.org
Fri Aug 30 06:47:35 MDT 2002


followup...

xargs works well enough from the command line, but I wound up building
another script.  The goal is to play all .mp3 files under a directory
_in_order_ since some of what I want to play are talking books, random
makes no sence, I have a different script for that.

Here is the recursive script:

[davep at dp:~]$ cat `which mpr`
#!/bin/bash
#mpr - recursively play mp3's in a directory
find $1 | grep .mp3 | sort > mpr.lst
mpg123 -C -b 1024 -@ mpr.lst
rm mpr.lst

Notes:

The -C lets you stop and pause playback; the -b sets up a buffer to
avoid dropouts.

I would have thought that the 'grep .mp3' pipe would eliminate directory
names themselves, but when I use an argument like '/local/mp3/led_zeppelin'
I wind up getting the empty directory names too; not just .mp3 files as
expected.

I tried using /var/tmp/ as the location for the temp file (mpr.lst) but
found that if i used 'relative paths' as arguments, mpg123 would prepend
the /var/tmp in front of the file name. e.g. 'mpr ./led_zeppelin' would
result in 'mpg123: /var/tmp/./led_zeppelin/xxxx file not found' ...
building the temp file in the working directory seems to sole this
nicely.  I can now mount a cd full of .mp3 files and 'mpr /cdrom' does
what i would expect.

FYIW here is the 'play what match's a regex script':

[davep at dp:~]$ cat `which mpg`
#1/bin/bash
locate .mp3 | grep -i $1 > playlist ; mpg123 -z -@ playlist

(This one does randomize)

aloha,
dave




More information about the clue-tech mailing list