Roger Upole wrote:
Kalibr wrote:
I've been trying to figure out how to find the details of files
(specifically music for now) for a little sorting script I'm making,
My aim is to get details on the artist, album, and genre for mp3 and
wma files (possibly more in the future). My closest match was when I
stumbled accross PyMedia, but it only supports up to 2.4 (I have 2.5).
Now I see a bit mentioned on GetFileVersionInfo, but that doesn't seem
to help (and most of it went over my head). Is there any module I can
use to find this sort of data? I'm trying to not make it specialised
in music, because I may want to extend this to picture, movie, text
etc. files in the future. Any ideas how I could go about this?

I think GetFileVersionInfo() only provides version information for DLL and EXE files.

See: http://msdn.microsoft.com/en-us/library/ms646981.aspx


You can use the shell COM objects to access media properties
as shown by Explorer.

import win32com.client
sh=win32com.client.Dispatch('Shell.Application')

folder= r'M:\Music\Bob Dylan\Highway 61 Revisited'
ns=sh.NameSpace(folder)

## the column index for Artist may vary from folder to folder
for c in range(0,255):
    colname=ns.GetDetailsOf(None, c)
    if colname=='Artists':  ## This shows up as just Artist on XP
        for i in ns.Items():
            artist=ns.GetDetailsOf(i, c)
            if artist:
                print ns.GetDetailsOf(i, 0), artist
        break


            Roger

Great tip, Roger! This solution works for WMA files (I don't have any MP3 files handy), so I think it would work for any media files in Windows.

--
Kam-Hung Soh <a href="http://kamhungsoh.com/blog";>Software Salariman</a>

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to