[python-win32] Re: NTFS/MS Word file metadata - no PIDSI for Category?

Roger Upole rwupole at msn.com
Fri Jul 14 04:24:38 CEST 2006


Earle Williams wrote:
> Hola,
> 
> I'm trying to pull extended file properties from NTFS or MSWord files.
> List archives point to snippets from Mark Hammond and Roger Upole, and I
> can get to most of the metadata.  However I'm having trouble getting to the
> 'Category' information.  It seems in the NTFS metadata that item is flagged
> with a PIDSI_TITLE constant, at least that's what I get with my code
> (hacked from testStorage.py).  If there is no 'Title' info and just
> Category info, the category info gets read as title.,
> 
> And in MSWord metadata I can't pull that info at all using Mark Hammond's
> DumpStorage snippet.  I get everything else but not the 'Category' data.
> 
> Anyone have advice on a method to definitively retrieve the category info?
> 

Category is part of DocSummaryInformation, so you'll need the PIDDSI*
constants instead of PIDSI*.  (PIDDSI_CATEGORY just happens to be
equal to PIDSI_TITLE)

from win32com import storagecon
import pythoncom
fname='c:\\tmp.doc'

pss=pythoncom.StgOpenStorageEx(fname, storagecon.STGM_READ|storagecon.STGM_SHARE_EXCLUSIVE,
    storagecon.STGFMT_DOCFILE, 0 , pythoncom.IID_IPropertySetStorage)
ps=pss.Open(pythoncom.FMTID_DocSummaryInformation)
print ps.ReadMultiple((storagecon.PIDDSI_CATEGORY,))[0]

     Roger






More information about the Python-win32 mailing list