Re: [greenstone-users] Extracting date from foldername

From John R. McPherson
DateThu, 3 Aug 2006 13:03:50 +1200
Subject Re: [greenstone-users] Extracting date from foldername
In-Reply-To (EE1AF18EB3686C459A38EBECE3BD51988D64B5-ex1-its-waikato-ac-nz)
On Thu, Aug 03, 2006 at 12:00:57PM +1200, James Brunskill wrote:
> Thanks Malathy,
> As I said in my email, I don't want to have to manually set the metadata
> for each folder (There are 164 of them).
> The folders are already named by their year, is it possible to use the
> folder names as extracted metadata?


I managed to achieve this by adding 5 lines to BasPlug as shown (in the
read_into_doc_obj() function):

# create a new document
my $doc_obj = new doc ($filename, "indexed_doc");
$doc_obj->set_OIDtype ($processor->{'OIDtype'});
+ my $import_subdir = dirname($file);
+ if ($import_subdir ne '.') {
+ $doc_obj->add_utf8_metadata($doc_obj->get_top_section(),
+ "ImportSubdir", $import_subdir);
+ }
$doc_obj->add_utf8_metadata($doc_obj->get_top_section(), "Language", $language);

If you then re-import your collection (deleting the old archived imported
version) then you will have a metadata field named ImportSubdir.