Ubuntu – How to generate an M3U playlist (http URL format) from the terminal

command linemp3musicplaylists

I'd like to generate a M3U playlist for a directory containing mp3 files on my server from the terminal. Since I'd like to ensure that every player will be able to stream those files I'd like to prefix each file entry with the absolute URL to that directory, like this:

http://server.com/dir/file1.mp3


...

So unfortunately simply doing ls -1 *.mp3 > play.m3u isn't enough. Is there a one-liner to achieve this?

Best Answer

I think the following one-liner should work:

for f in *.mp3; do echo "http://..../$f" >> play.m3u; done