How to get file tags in a list with Python (Windows Vista)?

I want to do something with a tag cloud for the various folders that I have, but unfortunately I cannot find a way to access the file tags in Windows Vista. I tried looking at the win32 module and os.stat, but I can not find a way. Can I get help on this?

+3
python windows-vista tags
source share
4 answers

I communicated with the win32 extension package along with some demo code that I found. I spoke in detail about this process to this topic . I don't want to reproduce all of this here, but here is a short version (click the link above for details).

  • Download and install the pywin32 extension .
  • Grab the code Tim Golden wrote for this very task.
  • Save the Tim code as a module on your own computer.
  • Call the property_sets method of your new module (supplying the necessary file path). The method returns a generator object that is iterable. See the following sample code and output.

(This works for me in XP, at least.)

eg.

 import your_new_module propgenerator= your_new_module.property_sets('[your file path]') for name, properties in propgenerator: print name for k, v in properties.items (): print " ", k, "=>", v 

The output of the above code will look something like this:

 DocSummaryInformation PIDDSI_CATEGORY => qux SummaryInformation PIDSI_TITLE => foo PIDSI_COMMENTS => flam PIDSI_AUTHOR => baz PIDSI_KEYWORDS => flim PIDSI_SUBJECT => bar 
+6
source share

Apparently you need to use the Windows Search API that System.Keywords is looking for - you can access the API directly through ctypes or indirectly ( win32 extensions are required) through the COM Interop API assembly. Sorry, I don’t have vista installed for verification, but I hope these links are useful!

+4
source share

Windows seems to be storing tags in files . Just mark any image and open the image in notepad and find something XML ( RDF ) and you will find your tag there. Well ... now we know that they are really stored in files, but we still don’t know how to manage them.

But Google is saving. I googled: windows api metadata

and found this: http://blogs.msdn.com/pix/archive/2006/12/06/photo-metadata-apis.aspx

+2
source share

In fact, there are 2 different implications of document properties ( source ).

  • The COM implementation implements them directly in the file itself: this is the approach used, for example, for Office documents. The Tim Gold Code described on this page is well suited for this purpose.

  • In NTFS 5 (Win2k or later), you can add summary information to any file and store it in alternative data streams. I believe the Windows Search API will work on this, but I have not tested it.

+1
source share

All Articles