Re: [greenstone-users] Creating metadata from file names

From Katherine Don
DateWed, 03 Mar 2004 14:24:16 +1300
Subject Re: [greenstone-users] Creating metadata from file names
In-Reply-To (00a001c3fec5$146c4c40$a900005a-Antigone)
Hi Mike

Can you not do this using metadata.xml files?:
<Metadata name="Subject" mode="accumulate">ThisTopic</Metadata>

The FileName elements are just regular expressions to match against the

Otherwise, if you want to add metadata to a file, you will need to modify the
plugins you are using.

To add metadata to a document at the top level:
if ($filename =~ /pattern/) {
my $cursection = $doc_obj->get_top_section();
$doc_obj->add_metadata($cursection, "Subject", "ThisTopic");

Add this into BasPlug in the read function: look for a line like
my $doc_obj = new doc ($filename, "indexed_doc");

and add it somewhere after that. Note that if you use plugins that redefine
their own read function, you will need to add it there too.


Mike Blyth wrote:

> I'd like to be able to create metatata from the file names of imported
> files. I'm doing a certain amount by using metadata.xml files with
> string-matching, but want to be able to do more. Could someone please give
> me a two-line example in perl (and tell me where to put it) along the lines
> of
> if filename matches "pattern" {add "ThisTopic" to Subject}
> Thanks in advance.
> --Mike Blyth
> ECWA Evangel Hospital
> Jos, Nigeria
> _______________________________________________
> greenstone-users mailing list