This should do the trick. Pretty much any media player can deal with .m3u playlists. You just need to edit a few things.
import os, string
def create_m3u_playlist(music_dir, name):
song_list = os.listdir(music_dir)
# change "/home/music/" to where you want the .m3u files to be created
f = open("/home/music/" + name + ".m3u" , "w")
for i in song_list:
f.write(music_dir + "/" + i + "\n")
# change "a","b" etc... to the directory names where you keep your music files.
directory = ["a","b","c"]
for name in directory :
# change "/home/music/" to the path to your music directories ie: "music_dir + name"
# should represent the full path to your directories.
music_dir = "/home/music/" + name
I edited this from a python script I wrote that indexes all of my music files into html pages and m3u playlists. Unfortunately my script is hardwired with file paths specific to my music directory structure, but anyone with a little python knowledge could hack it to work for them.