View | Details | Raw Unified | Return to bug 10421
Collapse All | Expand All

(-)a/misc/cronjobs/delete_deleted_records.pl (-1 / +89 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
use Modern::Perl;
4
use Getopt::Long;
5
use Pod::Usage;
6
7
use C4::Biblio;
8
use C4::Context;
9
10
my ($help, $confirm);
11
GetOptions(
12
    'h|help' => \$help,
13
    'c|confirm' => \$confirm,
14
);
15
16
pod2usage(1) if ( $help || !$confirm );
17
18
my $dbh = C4::Context->dbh;
19
20
my $sql = q{ SELECT biblionumber FROM biblioitems WHERE SUBSTR(marcxml,INSTR(marcxml, "<leader>")+8+5,1) = "d" };
21
22
my @biblionumbers = @{ $dbh->selectcol_arrayref($sql) };
23
24
foreach my $biblionumber ( @biblionumbers ) {
25
        print "Deleting biblionumber $biblionumber ... ";
26
        my $error;
27
        eval {
28
            $error = DelBiblio $biblionumber;
29
        };
30
        if ( $@ or $error) {
31
            say "ERROR: $@ ($! | $error)";
32
        } else {
33
            say "DONE!";
34
        }
35
}
36
37
exit(0);
38
39
__END__
40
41
=head1 NAME
42
43
delete_deleted_recordss.pl
44
45
=head1 SYNOPSIS
46
47
./delete_deleted_records.pl --confirm 
48
49
This script will batch delete all records where the leader's record status ( position 5 ) is set to 'd' ( Deleted ).
50
51
=head1 OPTIONS
52
53
=over 8
54
55
=item B<-h|--help>
56
57
prints this help message
58
59
=item B<-c|--confirm>
60
61
Confirm you really want to batch delete deleted records
62
63
=back
64
65
=head1 AUTHOR
66
67
Kyle M Hall <kyle@bywatersolutions.com>
68
69
=head1 COPYRIGHT
70
71
Copyright 2013 Kyle M Hall
72
73
=head1 LICENSE
74
75
This file is part of Koha.
76
77
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
78
Foundation; either version 2 of the License, or (at your option) any later version.
79
80
You should have received a copy of the GNU General Public License along
81
with Koha; if not, write to the Free Software Foundation, Inc.,
82
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
83
84
=head1 DISCLAIMER OF WARRANTY
85
86
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
87
A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
88
89
=cut

Return to bug 10421