Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

executable file 62 lines (49 sloc) 1.345 kb
#!/usr/bin/env perl
use Koha;
use Data::Dumper;
use C4::Context;
use C4::Biblio;
use C4::Items;
use MARC::Record;
use MARC::Field;
use Try::Tiny;
use Carp;
sub normalize_cn {
my $biblionumber = shift;
my $record = GetMarcBiblio($biblionumber);
return if !$record;
my $f086 = $record->field('086');
return if !$f086;
my $s = try {
Text::SuDocs->new($record->subfield('086', 'a'))
}
catch {
carp sprintf('Unparseable SuDocs (%s):%s', $record->subfield('086', 'a'), $_);
undef;
};
return if !$s;
$s = undef;
my $f942 = $record->field(942);
if ($f942) {
$record->delete_fields($f942);
}
else {
$f942 = MARC::Field->new('942', ' ', ' ', a=>123);
}
$f942->update(2 => 'sudocs',
h => $record->subfield('086', 'a'));
$record->insert_fields_ordered($f942);
try {
my (undef, $biblio) = GetBiblio($biblionumber);
ModBiblio($record, $biblionumber, $biblio->{frameworkcode});
}
catch {
carp "Unable to update $biblionumber: $_";
};
}
my $biblionumbers = [qw(2087 2088 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660)];
$biblionumbers = C4::Context->dbh->selectcol_arrayref('SELECT biblionumber FROM biblio');
for (@$biblionumbers) {
say $_;
normalize_cn($_);
}
Jump to Line
Something went wrong with that request. Please try again.