Created
August 2, 2015 19:49
-
-
Save shidarin/4c8d07508ff1fdd075a3 to your computer and use it in GitHub Desktop.
m3u playlist generator to help with retroarch emulator setup and multiple disks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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