Line 0
Link Here
|
0 |
- |
1 |
#!/usr/bin/perl |
|
|
2 |
|
3 |
# Copyright 2012 BibLibre |
4 |
# This file is part of Koha. |
5 |
# |
6 |
# Koha is free software; you can redistribute it and/or modify it under the |
7 |
# terms of the GNU General Public License as published by the Free Software |
8 |
# Foundation; either version 2 of the License, or (at your option) any later |
9 |
# version. |
10 |
# |
11 |
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY |
12 |
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
13 |
# A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
14 |
# |
15 |
# You should have received a copy of the GNU General Public License along with |
16 |
# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, |
17 |
# Suite 330, Boston, MA 02111-1307 USA |
18 |
|
19 |
=head1 batchdeletebiblios.pl |
20 |
|
21 |
This script batch deletes biblios which contain a biblionumber present in file passed in parameter. |
22 |
If one biblio has items, it is not deleted. |
23 |
|
24 |
=cut |
25 |
|
26 |
use Modern::Perl; |
27 |
use C4::Biblio; |
28 |
|
29 |
use IO::File; |
30 |
|
31 |
for my $file ( @ARGV ) { |
32 |
say "Find biblionumber in file $file"; |
33 |
open(FD, $file) or say "Error: '$file' $!" and next; |
34 |
|
35 |
while ( <FD> ) { |
36 |
my $biblionumber = $_; |
37 |
$biblionumber =~ s/$1/\n/g if $biblionumber =~ m/(\r\n?|\n\r?)/; |
38 |
chomp $biblionumber; |
39 |
my $dbh = C4::Context->dbh; |
40 |
next if not $biblionumber =~ /^\d*$/; |
41 |
print "Delete biblionumber $biblionumber "; |
42 |
my $error; |
43 |
eval { |
44 |
$error = DelBiblio $biblionumber; |
45 |
}; |
46 |
if ( $@ or $error) { |
47 |
say "KO $@ ($! | $error)"; |
48 |
} else { |
49 |
say "OK"; |
50 |
} |
51 |
} |
52 |
} |