Looking for a Program That Lists Metadata

Java, C++, C#, Delphi... - Using the UNO bridges
Post Reply
User avatar
Digger
Posts: 45
Joined: Sat Jan 14, 2012 11:29 pm

Looking for a Program That Lists Metadata

Post 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!
LibreOffice 5.2.7.2
Debian 9 (Stretch) (Linux)
User avatar
acknak
Moderator
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

Re: Looking for a Program That Lists Metadata

Post 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
AOO4/LO5 • Linux • Fedora 23
User avatar
peterroots
Volunteer
Posts: 299
Joined: Mon Mar 03, 2008 6:33 pm
Location: UK

Re: Looking for a Program That Lists Metadata

Post by peterroots »

Well done :-) I had a go at this on Monday and failed dismally to get it to work!
LibreOffice 4.0.3 OpenSUSE 12.3 : OpenOffice 4 Linux Mint 15
User avatar
Digger
Posts: 45
Joined: Sat Jan 14, 2012 11:29 pm

Re: Looking for a Program That Lists Metadata

Post 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!
LibreOffice 5.2.7.2
Debian 9 (Stretch) (Linux)
Post Reply