Accessing Windows file metadata?

Discussion in 'Python' started by EP, Jan 11, 2006.

  1. EP

    EP Guest

    I'm looking for a method by which to access Windows files metadata and
    have not been able to find anything in the standard modules or via
    Google - what is the standard approach?

    Shamefully I really do not understand Windows file system - e.g. is
    properties metadata attached to the file? if I change that metadata
    do I change the file's hash? how is the metadata structured? or is
    the "properties" metadata simply derived upon access?

    Either way, is there a module or method to access this metadata (I'd
    hope there was a metadata dictionary for each file, but that may be a
    sign I've been spoiled by Python) ?


    EP
     
    EP, Jan 11, 2006
    #1
    1. Advertising

  2. EP

    Roger Upole Guest

    The Pywin32 package wraps the interfaces used to read and
    write these properties. \win32com\test\testStorage.py demonstrates
    how to use them.

    There are actually two different ways that metadata is stored.
    For structured storage files created by COM applications, it's
    embedded directly in the file data. This would change the file's hash
    if the document properties were changed. On volumes formatted
    with NTFS 5 (Win2k and later), document properties can be added
    to any type of file and are stored in alternate data streams.

    hth
    Roger



    "EP" <> wrote in message news:...
    > I'm looking for a method by which to access Windows files metadata and
    > have not been able to find anything in the standard modules or via
    > Google - what is the standard approach?
    >
    > Shamefully I really do not understand Windows file system - e.g. is
    > properties metadata attached to the file? if I change that metadata
    > do I change the file's hash? how is the metadata structured? or is
    > the "properties" metadata simply derived upon access?
    >
    > Either way, is there a module or method to access this metadata (I'd
    > hope there was a metadata dictionary for each file, but that may be a
    > sign I've been spoiled by Python) ?
    >
    >
    > EP
    >





    ----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
    http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
    ---= East/West-Coast Server Farms - Total Privacy via Encryption =---
     
    Roger Upole, Jan 12, 2006
    #2
    1. Advertising

  3. EP

    John Rhoads Guest

    Probably somebody more deeply into this will soon give you a better answer,
    but I'll
    try to give a better-than-nothing answer.

    The Properties metadata that you see in the shell can come from several places.
    The oldest, commonest source is from Microsoft Office files. These have a
    compound
    structure associated with OLE Object Linking and Embedding and the metadata
    is just one
    of a lot of things stuck in there besides the Word text or Excel numbers
    you see in the
    application.

    Getting to it from Python is via COM. See Mark Hammond and Andy Robinson's
    book
    "Python Programming in Win32" for the general approach. Perhaps the easiest
    way to
    get this metadata is using DSOFILE.DLL that was released as an example a long
    time ago by Microsoft (it's not an OS file, you have to install it yourself).


    The following article gives a VBScript example that you can
    use as a template for your Python.

    http://www.microsoft.com/technet/community/columns/scripts/sg0305.mspx

    As I said, the OLE metadata has been around for a long time. With Windows
    2000, MS
    extended the idea to any NTFS file so that you have an open-ended ability to
    associate named attributes like author, title, keywords or custom attributes
    of your
    own to any file on an NTFS partition.

    Unfortunately DSOFILE does not help with this (at least I don't think so!),
    so you'd need
    to deal with the OS at a somewhat uglier level. And obviously you need Win2K
    or better.

    Look at \win32com\test\testStorage.py in the win32 python package for an
    example.

    Hope this helps,


    John Rhoads


    > I'm looking for a method by which to access Windows files metadata and
    > have not been able to find anything in the standard modules or via
    > Google - what is the standard approach?
    >
    > Shamefully I really do not understand Windows file system - e.g. is
    > properties metadata attached to the file? if I change that metadata
    > do I change the file's hash? how is the metadata structured? or is
    > the "properties" metadata simply derived upon access?
    >
    > Either way, is there a module or method to access this metadata (I'd
    > hope there was a metadata dictionary for each file, but that may be a
    > sign I've been spoiled by Python) ?
    >
    > EP
    >
     
    John Rhoads, Jan 12, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    1,640
    Ken Cox - Microsoft MVP
    Mar 17, 2006
  2. Brett Selleck

    Schema Metadata not a Metadata Schema

    Brett Selleck, Sep 4, 2003, in forum: XML
    Replies:
    1
    Views:
    435
    Andy Dingley
    Sep 4, 2003
  3. Replies:
    3
    Views:
    606
    Roger Upole
    Nov 28, 2006
  4. Tim Golden
    Replies:
    0
    Views:
    486
    Tim Golden
    Nov 28, 2006
  5. Mike Wazowski

    Accessing Windows Media Metadata from Classic ASP

    Mike Wazowski, Sep 4, 2009, in forum: ASP General
    Replies:
    2
    Views:
    848
    Mike Wazowski
    Sep 7, 2009
Loading...

Share This Page