Skip to content

Instantly share code, notes, and snippets.

@shidarin
Created August 2, 2015 19:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shidarin/4c8d07508ff1fdd075a3 to your computer and use it in GitHub Desktop.
Save shidarin/4c8d07508ff1fdd075a3 to your computer and use it in GitHub Desktop.
m3u playlist generator to help with retroarch emulator setup and multiple disks
#!/usr/bin/python
"""This script will create an m3u file with a tracklist of each .cue or .ccd
found in a subdirectory, then name the m3u after the subdirectory. This helps
with multiple disks for emulation.
"""
import os
import os.path
EXT = ['.cue', '.ccd']
cwd = os.getcwd()
dirs = os.listdir(cwd)
for d in dirs:
contents = os.listdir(os.path.join(cwd, d))
disks = [
os.path.join(d, f) for f in os.listdir(os.path.join(cwd, d))
if os.path.splitext(f)[-1] in EXT
]
if disks:
with open(os.path.join(cwd, '{d}.m3u'.format(d=d)), 'wb') as m3u:
m3u.writelines(['{disk}\n'.format(disk=disk) for disk in disks])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment