extract just documents which have files
authordpavlin <dpavlin@rot13.org>
Thu, 21 May 2015 12:56:45 +0000 (14:56 +0200)
committerdpavlin <dpavlin@rot13.org>
Thu, 21 May 2015 12:56:45 +0000 (14:56 +0200)
snz-rebuild.sh
tsv2eprints.pl

index 6194fec..b0a449f 100755 (executable)
@@ -1,8 +1,13 @@
 #!/bin/sh -xe
 
+
 #cd "/mnt/share/MKP/ELEKTRONIÄŒKI DOKUMENTI/EL.DOKUMENTI PO BIBLIOBROJU/do18052015/"
 #find . -name '[0-9]*.pdf' -print | sed 's,./,,' | tee pdf-files.list
+
 sudo -u eprints /usr/share/eprints3/bin/epadmin update snz
+
+./tsv2eprints.pl
+
 sudo -u eprints /usr/share/eprints3/bin/epadmin --force erase_eprints snz
-sudo -u eprints /usr/share/eprints3/bin/import --update --migration --enable-web-imports --enable-file-imports --enable-import-fields --force snz eprint MARC /tmp/koha_ffzg.marc
+sudo -u eprints /usr/share/eprints3/bin/import --update --migration --enable-web-imports --enable-file-imports --enable-import-fields --force snz eprint MARC /tmp/koha_ffzg.import.marc
 sudo -u eprints /usr/share/eprints3/bin/generate_views snz
index 62e7521..7535069 100755 (executable)
@@ -249,8 +249,11 @@ print qq{<?xml version="1.0" encoding="utf-8" ?>
 };
 
 
-open(my $tsv_fh,   '<:encoding(UTF-8)', "$koha_path.tsv");
-open(my $tsv_marc, '<:encoding(UTF-8)', "$koha_path.marc");
+open(my $tsv_fh,  '<:encoding(UTF-8)', "$koha_path.tsv");
+open(my $marc_fh, '<', "$koha_path.marc");
+open(my $import_fh, '>', "$koha_path.import.marc");
+
+my $last_offset = 0;
 
 while(<$tsv_fh>) {
        my $line = $_;
@@ -266,10 +269,18 @@ while(<$tsv_fh>) {
 
        if ( $item->{full_path} = $files->{$biblionumber} ) {
                $stat->{file}++;
+
+               seek $marc_fh, $last_offset, 0;
+               read $marc_fh, my $marc, $offset - $last_offset;
+               print $import_fh $marc;
+               warn "# marc $biblionumber $title\n";
+
        } else {
                $stat->{missing}++;
        }
 
+       $last_offset = $offset;
+
 }
 
 print qq{