12 # command-line parameters
16 my $batch_comment = "";
19 my $result = GetOptions(
20 'file:s' => \$input_file,
21 'match-bibs' => \$match_bibs,
22 'add-items' => \$add_items,
23 'comment:s' => \$batch_comment,
24 'h|help' => \$want_help
27 if (not $result or $input_file eq "" or $want_help) {
32 unless (-r $input_file) {
33 die "$0: cannot open input file $input_file: $!\n";
36 process_batch($input_file, $match_bibs, $add_items, $batch_comment);
41 my ($input_file, $match_bibs, $add_items, $batch_comment) = @_;
43 open IN, "<$input_file" or die "$0: cannot open input file $input_file: $!\n";
44 my $marc_records = "";
46 my $num_input_records = 0;
48 $marc_records .= $_; # FIXME - this sort of string concatenation
49 # is probably rather inefficient
54 my $marc_flavor = C4::Context->preference('marcflavour');
56 print "... staging MARC records -- please wait\n";
57 my ($batch_id, $num_valid, $num_items, @import_errors) =
58 BatchStageMarcRecords($marc_flavor, $marc_records, $input_file, $batch_comment, '', $add_items, 0,
59 100, \&print_progress);
60 print "... finished staging MARC records\n";
62 my $num_with_matches = 0;
64 my $matcher = C4::Matcher->new('biblio');
65 $matcher->add_matchpoint("020", "a", '', 'isbn', 1000);
66 print "... looking for matches with records already in database\n";
67 $num_with_matches = BatchFindBibDuplicates($batch_id, $matcher, 10, 100, \&print_progress);
68 print "... finished looking for matches\n";
71 my $num_invalid_bibs = scalar(@import_errors);
74 MARC record staging report
75 ------------------------------------
76 Input file: $input_file
77 Number of input bibs: $num_input_records
78 Number of valid bibs: $num_valid
79 Number of invalid bibs: $num_invalid_bibs
82 print "Number of bibs matched: $num_with_matches\n";
84 print "Incoming bibs not matched against existing bibs (--match-bibs option not supplied)\n";
87 print "Number of items parsed: $num_items\n";
89 print "No items parsed (--add-items option not supplied)\n";
93 print "Batch number assigned: $batch_id\n";
99 print "... processed $recs records\n";
104 $0: stage MARC bib file into reservoir.
106 Use this batch job to load a file of MARC bibliographic records
107 (with optional item information) into the Koha reservoir.
109 After running this program to stage your file, you can use
110 either the batch job commit_biblios_file.pl or the Koha
111 Tools option "Manage Staged MARC Records" to load the
112 records into the main Koha database.
115 --file <file_name> name of input MARC bib file
116 --match-bibs use this option to match bibs
117 in the file with bibs already in
118 the database for future overlay.
119 --add-items use this option to specify that
120 item data is embedded in the MARC
121 bibs and should be parsed.
122 --comment <comment> optional comment to describe
123 the record batch; if the comment
124 has spaces in it, surround the
125 comment with quotation marks.
126 --help or -h show this message.