import os, inspect import subprocess musicdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))+"/music"+"/1" for (path, dirnames, filenames) in os.walk(musicdir): #folders.extend(os.path.join(path, name) for name in dirnames) for name in filenames: file = os.path.join(path, name) #os.system("mpg123 " + "'" + file + "'") #os.system("") subprocess.run(["mpg123", file])