Skip to content

Instantly share code, notes, and snippets.

@feltnerm
Created April 19, 2011 05:51
Show Gist options
  • Save feltnerm/926884 to your computer and use it in GitHub Desktop.
Save feltnerm/926884 to your computer and use it in GitHub Desktop.
display simple tracklist info about a directory of mp3s
#!/usr/bin/env python
"""
audinf.py
Displays simple track info about a list of mp3s
"""
import sys
import os
from mutagen.easyid3 import EasyID3 as eid3
def print_tags(f):
audio = eid3(f)
try:
artist = audio['artist'][0]
title = audio['title'][0]
print "%s - %s" % (artist, title)
except KeyError:
print f
def main():
cwd = os.getcwd()
for p,n,files in os.walk(cwd):
print 'Found %s files.' % len(files)
for f in files:
if ('.mp3' or '.flac' or '.mp4' or '.aac' or '.ogg' or '.m4a') in f:
print_tags(f)
return 0 # success !
if __name__ == "__main__":
status = main()
sys.exit(status)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment