General discussion

Locked

Scripting problem!

By bmw ·
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.

This conversation is currently closed to new comments.

5 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Scripting problem!

by ianATonlineloop.NOcom In reply to Scripting problem!

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

Collapse -

Scripting problem!

by bmw In reply to Scripting problem!

Poster rated this answer

Collapse -

Scripting problem!

by servermonkey In reply to Scripting problem!

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.

Collapse -

Scripting problem!

by bmw In reply to Scripting problem!

Poster rated this answer

Collapse -

Scripting problem!

by bmw In reply to Scripting problem!

This question was closed by the author

Back to Linux Forum
5 total posts (Page 1 of 1)  

Related Discussions

Related Forums