Richard Bucker

Make M3u Playlist

Posted at — Jun 14, 2023

There may be plenty of documentation out there for generating M3U files. The challenge is finding the authority. In fact I found a few variations that simply did not work.

This works

#!/bin/sh

OIFS="$IFS"; IFS=$'\n'; n=1; echo "#EXTM3U"; for f in $(ls -1 *mp3);do echo ""; echo "#EXTINF:${n},$f"; echo "$f"; n=$((n+1)); done; IFS="$OIFS" 

I suppose I could have spent a lot of time trying to extract the song name from the filename and then construct the menu entry. But then I would also need to find the path of the music file and fix that too. Too many mp3 devices have different folder structions.

Make it work and moving on….