Skip to content

Instantly share code, notes, and snippets.

@santiago-salas-v
Created May 14, 2018 11:13
Show Gist options
  • Save santiago-salas-v/1f11ad0541397bae11429ba9c0e2e08d to your computer and use it in GitHub Desktop.
Save santiago-salas-v/1f11ad0541397bae11429ba9c0e2e08d to your computer and use it in GitHub Desktop.
get metadata of mp3 files
import os
import win32com.client
folder = os.path.abspath(u'.')
folder_exists = os.path.exists(folder)
sh=win32com.client.gencache.EnsureDispatch('Shell.Application',0)
ns=sh.NameSpace(folder)
colnum = 0
columns = []
while True:
colname=ns.GetDetailsOf(None,colnum)
if not colname:
break
columns.append(colname)
colnum+=1
print(columns)
relevant_columns = [columns.index(x) for x in [
'Titel', 'Titelnummer', 'Mitwirkende Interpreten'
]]
print(relevant_columns)
for item in ns.Items():
print(str(item).split('_'))
for colnum in relevant_columns:
colval = ns.GetDetailsOf(item, colnum)
if colval:
print('\t', columns[colnum], colval)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment