Reading metadata with Python

前端 未结 5 1467
囚心锁ツ
囚心锁ツ 2020-12-09 23:54

For the past two days I have been scanning the Internet to try to find the solution to my problem. I have a folder of different files. They run the gambit of file types. I a

5条回答
  •  没有蜡笔的小新
    2020-12-10 00:32

    You can use the Shell com objects to retrieve any metadata visible in Explorer:

    import win32com.client
    sh=win32com.client.gencache.EnsureDispatch('Shell.Application',0)
    ns = sh.NameSpace(r'm:\music\Aerosmith\Classics Live!')
    colnum = 0
    columns = []
    while True:
        colname=ns.GetDetailsOf(None, colnum)
        if not colname:
            break
        columns.append(colname)
        colnum += 1
    
    for item in ns.Items():
        print (item.Path)
        for colnum in range(len(columns)):
            colval=ns.GetDetailsOf(item, colnum)
            if colval:
                print('\t', columns[colnum], colval)
    

提交回复
热议问题