@@ -, +, @@ perl misc/maintenance/update_authorities.pl -authid X,Y -del --- misc/maintenance/update_authorities.pl | 78 ++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 misc/maintenance/update_authorities.pl --- a/misc/maintenance/update_authorities.pl +++ a/misc/maintenance/update_authorities.pl @@ -0,0 +1,78 @@ +#!/usr/bin/perl + +# Copyright Rijksmuseum 2017 +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +use Modern::Perl; + +use Getopt::Long; +use List::MoreUtils qw/uniq/; +use Pod::Usage; + +use C4::AuthoritiesMarc qw/DelAuthority merge/; + +my ( @authid, $delete, $help, $verbose ); +GetOptions( + 'authid:s' => \@authid, + 'delete' => \$delete, + 'help' => \$help, + 'verbose' => \$verbose, + # TODO Add more options under BZ 18071 +); + +if( $delete ) { + @authid = map { split /[,]/, $_; } @authid; + foreach my $authid ( uniq(@authid) ) { + DelAuthority( $authid ); # triggers a merge (read: cleanup) + print "Removing $authid\n" if $verbose; + } +} elsif( $help ) { + pod2usage(1); +} else { + pod2usage(1); +} + +=head1 NAME + +update_authorities.pl + +=head1 DESCRIPTION + +Script to perform various authority related maintenance tasks. +This version supports deleting an authority record and updating all linked +biblio records. +On BZ report 18071 we will add functions like: updating 001, triggering merge. + +=head1 SYNOPSIS + +update_authorities.pl -authid 1,2,3 -delete + +update_authorities.pl -authid 1 -authid 2 -authid 3 -delete + +=head1 OPTIONS + +authid: List authority numbers separated by commas or repeat the +parameter. + +delete: Delete the listed authority numbers and remove its references from +linked biblio records. + +=head1 AUTHOR + +Marcel de Rooy, Rijksmuseum Amsterdam, The Netherlands + +=cut --