LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Program to create playlists of directories (https://www.linuxquestions.org/questions/linux-software-2/program-to-create-playlists-of-directories-198691/)

Mikessu 06-28-2004 11:06 AM

Program to create playlists of directories
 
Is there a program for Linux that can make playlist automatically from many directories at the same time? Or maybe a console program for that so I could write a script / execute it recursively to create playlists?

I want to make playlists for directories seperately not only one huge playlist containing all my music files.

Tinkster 06-28-2004 12:36 PM

http://www.catb.org/~esr/faqs/smart-questions.html

Which player are they meant to be for?




Cheers,
Tink

bulliver 06-28-2004 07:17 PM

This should do the trick. Pretty much any media player can deal with .m3u playlists. You just need to edit a few things.
Code:

#!/usr/bin/python

import os, string

def create_m3u_playlist(music_dir, name):
    song_list = os.listdir(music_dir)
    song_list.sort()
    # 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")
    f.close()

# 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
    create_m3u_playlist(music_dir, 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.


All times are GMT -5. The time now is 05:05 AM.