Discussion Locked

Scripting problem!

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hi,

I have RedHat Linux installed on on a crappy old laptop that I have hooked up to an amplifier, and I want to use it to play mp3 files that it finds in my '/mnt/music' directory (it has lots of sub directories for each band).
What i want, is a script that will play mp3 files using a wildcard.
I am using 'plaympeg' to listen to the songs, and I have had a go at creating a script to do what i want ......

for file in `find /mnt/music -name "*REM*.mp3" -print2`
do
plaympeg "$file"
done

..... however, the script seems to have problems with songs with spaces in eg
REM - Orange Crush.mp3 fails as it says it can't play "Orange" then can't play "Crush" etc etc.

Can you see what I am doing wrong?
Is there a smarter way to do this? (I am sure there is!)

Thanks,

Ben.

5 replies

by ianatonlineloop.nocom

Using find will generally not play the tracks
randomly, find will simply locate individual
files in the order they appear in the directory
structure. That particular issue I haven't
solved yet, however to solve your spaces in the
track names issue, try using find in the
following manner:
"find /mnt/music -name "*REM*.mp3" -exec
plaympeg \{\} \;"
For each file it finds with the extension
".mp3", it will call plaympeg, and the spaces
stop being a problem.

Hope this helps.
Ian

by servermonkey

I would load all of the file names into an array (probably use perl) generate a random number and select that element from the array to play.

This discussion is closed to new replies.