Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Access extended MS file properties

73 views
Skip to first unread message

rick h

unread,
Jun 22, 2016, 9:29:02 AM6/22/16
to
Am trying to access some file properties not supported with file attr or fileutils.

For example, MS identifies a Description property.

However that is not accessible via the aformentioned software.

Have looked at twapi, TclX, Storage {from PT), etc. to no avail.

Any suggestions (relevant) or scripts would be welcomed. Am not a C# programmer but have some experience with TCOM. So wish to stay within TCL.

rick h

unread,
Jun 22, 2016, 9:31:00 AM6/22/16
to
On Wednesday, June 22, 2016 at 9:29:02 AM UTC-4, rick h wrote:
> Am trying to access some file properties not supported with file attr or fileutils.
>
> For example, MS identifies a Description property.
>
> However that is not accessible via the aformentioned software.
>
> Have looked at twapi, TclX, Storage {from PT -failed on Open), etc. to no avail.

pal...@yahoo.com

unread,
Jun 22, 2016, 10:29:07 AM6/22/16
to
The CAWT package provides a GetDocumentProperty for Office files. See http://www.posoft.de/download/extensions/Cawt/CawtReference.html#::Office::GetDocumentProperty

Not sure if that's exactly what you are looking for but I have used it in the past to retrieve basic info like author.

/Ashok

Kevin Kenny

unread,
Jun 22, 2016, 2:15:42 PM6/22/16
to
On Wednesday, June 22, 2016 at 9:29:02 AM UTC-4, rick h wrote:
> Am trying to access some file properties not supported with file attr or fileutils.
>
> For example, MS identifies a Description property.
>
> However that is not accessible via the aformentioned software.

If you're talking about versions of Office from the last decade, the .xlsx, .docx, .pptx files are all ZIP files containing XML documents.

Try something like:

# Require packages for ZIP files and XML documents
package require vfs::zip
package require tdom

# Open an Office document and read the core properties
set path c:/path/to/the/document.docx
vfs::zip::Mount $path $path
set f [open $path/docProps/core.xml r]; set data [read $f]; close $f
vfs::filesystem::unmount $path

# Parse the core properties, extract 'lastModifiedBy' and print it
set doc [dom parse $data]
set root [$doc documentElement]
foreach node [$root getElementsByTagName cp:lastModifiedBy] {
puts [$node text]
}

Kevin Kenny

unread,
Jun 22, 2016, 2:25:37 PM6/22/16
to
And if the properties you want aren't in core.xml, try app.xml instead. For a Word document, I see that the latter contains properties named Template, TotalTime, Pages, Words, Characters, Application, DocSecurity, Lines, Paragraphs, ScaleCrop, HeadingPairs, TitlesOfParts, Company, LinksUpToDate, CharactersWithSpaces, SharedDoc, HyperlinksChanged, and AppVersion. The core properties that I see are dc:title, dc:subject, dc:creator, cp:keywords, dc:description, cp:lastModifiedBy, cp:revision, dcterms:created, and dcterms:modified.

Kevin Kenny

unread,
Jun 22, 2016, 2:36:57 PM6/22/16
to
Another afterthought: you're really not supposed to go after docProps/core.xml and docProps/app.xml directly (although everyone does). If you want to be more formally correct, first open $path/_rels/.rels (it's an XML document as well), and look for the <Relationship> elements within the <Relationships> element. The ones whose Type's are 'core-properties' and 'extended-properties' are the ones that you want. (There may also be a 'custom-properties', which will point to $path/docProps/custom.xml.)

rick h

unread,
Jun 22, 2016, 3:30:44 PM6/22/16
to
On Wednesday, June 22, 2016 at 2:36:57 PM UTC-4, Kevin Kenny wrote:
> Another afterthought: you're really not supposed to go after docProps/core.xml and docProps/app.xml directly (although everyone does). If you want to be more formally correct, first open $path/_rels/.rels (it's an XML document as well), and look for the <Relationship> elements within the <Relationships> element. The ones whose Type's are 'core-properties' and 'extended-properties' are the ones that you want. (There may also be a 'custom-properties', which will point to $path/docProps/custom.xml.)

Thanks, but not necessarily looking for Office docs'; just simple txt files.

rick h

unread,
Jun 22, 2016, 3:31:06 PM6/22/16
to

rick h

unread,
Jun 22, 2016, 3:36:19 PM6/22/16
to
Thanks, the files contain text created within tcl code. I have added my own extension, but otherwise simple text files.

Would the code work in this instance?

Would like to, then, use MS Windows Explorer to show contents.

Rick

rick h

unread,
Jun 22, 2016, 3:56:25 PM6/22/16
to
On Wednesday, June 22, 2016 at 10:29:07 AM UTC-4, pal...@yahoo.com wrote:
Thanks,

Just looked at CAWT. Seems it is focused on Office specific file types.

In this instance, the tcl app is creating files containing widget properties. They are simply 'text' files with an arbitrary extension (.sfx). Want to maintain Title, Description, etc within the context of a specific file, then use Windows Explores to list this info along with the usual Date, Type, Size etc.

Brad Lanam

unread,
Jun 22, 2016, 5:24:47 PM6/22/16
to
I think this answers your question:

http://stackoverflow.com/questions/21712052/create-a-file-with-windows-property-store-metadata-using-win32-api

Unless windows knows about .sfx files and .sfx files have properties that can be set, it's not possible.


wheel...@yahoo.com

unread,
Jun 24, 2016, 8:26:13 PM6/24/16
to
Soo true...

I used tcom to drill down to the properties/methods associated with the file namespace, folders and the file, itself.

However, one can get most of what's there from the tcl 'file' command.

What faked me out was the ability MS provides for selecting from a variety of properties for inclusion as column headers in a windows explorer when displaying the contents of a folder.

Thanks for the help...
0 new messages