Created
July 8, 2013 20:17
-
-
Save lardissone/5952123 to your computer and use it in GitHub Desktop.
List all artists in a MP3 directory and subdirectories
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
from os import walk | |
from mutagen.mp3 import MP3 | |
mypath = '/Volumes/Macintosh HD/Media/Music/iTunes/' | |
mypath = '/Volumes/Media HD/MP3/' | |
f = [] | |
artists = [] | |
a = 0 | |
b = 0 | |
output = open('output.txt', 'w') | |
for (dirpath, dirnames, filenames) in walk(mypath): | |
#b += 1 | |
if filenames: | |
for fn in filenames: | |
if '.mp3' in fn: | |
filepath = '%s/%s' % (dirpath, fn) | |
try: | |
audio = MP3(filepath) | |
artist = audio['TPE1'].text[0] | |
if artist not in artists: | |
a += 1 | |
print a, artist | |
artists.append(artist) | |
output.write('%s\n' % artist) | |
except: | |
pass | |
#if b == 20: | |
# break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment