win32 file attributes

Tim Golden tim.golden at viacom-outdoor.co.uk
Fri Aug 29 04:48:09 EDT 2003


David Bear <david.bear at asu.edu> wrote in message news:<m3wucxo1te.fsf at moroni.pp.asu.edu>...
> Using the windows explorer it is possible to get file properties which
> include under the version tab, 'company name', 'version', etc.  I'm
> assuming these metadata are actually stored in the exe somewhere.  Is
> there an api exposed to python that would allow me to get this info?
> 
> a scan of Mark Hammonds win32all package did have anything obvious
> jump out at me...

This isn't the first time this query has come up. Use Google to search
c.l.py for GetFileVersionInfo and see if any of those links helps you
out. I seem to remember seeing someone's Python wrapper for this
really recently, but for the life of me I can't put my finger on it
now. FWIW, here's my twopence-ha'penny worth:

1) Get wmi (http://tgolden.sc.sabren.com/python/wmi.html)
2) Try this:

<code>

import os
from glob import glob

import wmi

c = wmi.WMI ()
for exe in glob ("c:\\winnt\\*.exe"):
  for f in c.CIM_DataFile (Name=exe):
    print os.path.basename (f.Name), "is at version", f.Version

</code>

TJG




More information about the Python-list mailing list