Page 1 of 1

Looking for a Program That Lists Metadata

Posted: Mon Oct 01, 2012 6:57 pm
by Digger
Hello all,

I've been using a great little program called Loook that allows me to search within a directory of OpenOffice Write files for specific snippets of text. It works really well.

I am looking for a program that will search OpenOffice files within a directory for specific meta data. For example, I have hundreds of Write files that all have meta data entries containing the embedded title of the document.

An example from one of these files:

Code: Select all

<meta:user-defined meta:name="Matter">CLUTCH CABLE (LOWER) - REMOVAL<
Here, "CLUTCH CABLE (LOWER) - REMOVAL" is the title of the document.

How can I quickly generate a list of titles for all of the documents in the directory?

TIA!

Re: Looking for a Program That Lists Metadata

Posted: Tue Oct 02, 2012 3:17 am
by acknak
Something like this, maybe?

function _dn () { echo -n "$1: "; unzip -p "$1" meta.xml|sed -ne 's,.*<meta:user-defined meta:name="Matter">\([^<]*\)</meta:user-defined>.*,\1,p'; echo; }
function docname () { while [ $# -gt 0 ]; do _dn "$1"; shift; done; }

Paste those into a shell session, then you can run: docname file.odt to print the property for that file:

file.odt: CLUTCH CABLE (LOWER) - REMOVAL

or docname *.odt to do the same for all matching files:

aaa.odt: A is for Aardvark
bbb.odt: B is for Bonobo
ccc.odt: C is for Chameleon
...

To see only files with the property matching a specific pattern, do docname *.odt | grep Aardvark

aaa.odt: A is for Aardvark

Re: Looking for a Program That Lists Metadata

Posted: Wed Oct 03, 2012 10:04 pm
by peterroots
Well done :-) I had a go at this on Monday and failed dismally to get it to work!

Re: Looking for a Program That Lists Metadata

Posted: Wed Oct 10, 2012 6:25 am
by Digger
acknak wrote:Something like this, maybe?

function _dn () { echo -n "$1: "; unzip -p "$1" meta.xml|sed -ne 's,.*<meta:user-defined meta:name="Matter">\([^<]*\)</meta:user-defined>.*,\1,p'; echo; }
function docname () { while [ $# -gt 0 ]; do _dn "$1"; shift; done; }

Paste those into a shell session, then you can run: docname file.odt to print the property for that file:

file.odt: CLUTCH CABLE (LOWER) - REMOVAL

or docname *.odt to do the same for all matching files:

aaa.odt: A is for Aardvark
bbb.odt: B is for Bonobo
ccc.odt: C is for Chameleon
...

To see only files with the property matching a specific pattern, do docname *.odt | grep Aardvark

aaa.odt: A is for Aardvark

Thanks, Ack....I'll give it a go when I get a chance!