0

Suppose I have a directory which contains .mp3 and .ini files I want my program to select all the files with .mp3 and play them. Not as separate files but all at once means that when normally you select a few songs and play, it would create a playlist inside your default player. I want to do that.

Any help would be appreciated

Note from comment:

I know how to list all of the items. What I want to know is how to play all of them so that it creates a playlist of them so that when the first one finishes the second one automatically plays.

or How can i enter a folder click ctrl a and hit enter without it actually showing on the screen?

This could solve my problem

2 Answers2

0

Use the glob library.

from glob import glob
files = glob("/home/some_folder/*.mp3")
print(files)
CypherX
  • 7,019
  • 3
  • 25
  • 37
0

You can try to create .m3u files iteratively, it looks something like this

/home/songs/01.mp3
/home/songs/02.mp3
/home/songs/03.mp3

And then simply play .m3u files