I want to make something of a tag cloud for various folders I have, but unfortunately, I can\'t seem to find a way to access the tags of a file in Windows Vista. I tried loo
Apparently, you need to use the Windows Search API looking for System.Keywords -- you can access the API directly via ctypes, or indirectly (needing win32 extensions) through the API's COM Interop assembly. Sorry, I have no vista installation on which to check, but I hope these links are useful!
It appears that Windows stores the tags in the files. Just tag any image and open the image in notepad and look for something XML-like(RDF) and you will find your tag there. Well... now we know that they are indeed stored in the files, but we still have no idea how to manipulate them.
But google is to the rescue. I googled: windows metadata api
and found this: http://blogs.msdn.com/pix/archive/2006/12/06/photo-metadata-apis.aspx
There are actually 2 different implentations of document properties (source).
The COM implementation embeds them directly in the file itself : this is the approach used for Office documents for example. Tim Golden's code described on this page works well for these.
On NTFS 5 (Win2k or later), you can add Summary info to any file, and it's stored in alternate data streams. I suppose the Windows Search API would work on these, but I have not tested it.
I went about it with the win32 extensions package, along with some demo code I found. I posted a detailed explanation of the process on this thread. I don't want to reproduce it all here, but here is the short version (click the foregoing link for the details).
property_sets
method of your new module (supplying the necessary filepath). The method returns a generator object, which is iterable. See the following example code and output.(This works for me in XP, at least.)
E.g.
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 be something like the following:
DocSummaryInformation
PIDDSI_CATEGORY => qux
SummaryInformation
PIDSI_TITLE => foo
PIDSI_COMMENTS => flam
PIDSI_AUTHOR => baz
PIDSI_KEYWORDS => flim
PIDSI_SUBJECT => bar