[r531]: marc-tools / trunk / updateMarcForKoha.pl Maximize Restore History

Download this file

updateMarcForKoha.pl    428 lines (358 with data), 20.8 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
#!/usr/bin/perl -w
## updateMarcForKoha.pl
## Usage: fixMarc.pl -i inputfile -o outputfile -b branchcode -t marctype [-v] [-h]
## Copyright 2006 Kyle Hall
## This file is part of koha-tools.
## koha-tools 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 2 of the License, or
## (at your option) any later version.
## koha-tools 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-tools; if not, write to the Free Software
## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
use Getopt::Long;
use Pod::Usage;
use MARC::Batch;
use SimpleMARC;
use strict;
## Redirect STDERR to STDOUT
open STDERR, ">&STDOUT" or die "cannot dup STDERR to STDOUT: $!\n";
## get command line options
my ($input_file, $output_file, $marc_standard, $verbose, $branchcode, $vendor) = get_options();
print "Starting updateMarcForKoha\n" if $verbose;
print "MARC Standard : $marc_standard\n" if $verbose;
print "Input File: $input_file\n" if $verbose;
print "Output File: $output_file\n" if $verbose;
print "For Branchcode $branchcode\n" if $verbose;
print "For Vendor $vendor\n" if $verbose;
my $batch = MARC::Batch->new($marc_standard, $input_file);
## open a file handle to write our updated marc file to
open(OUT, ">$output_file") or die $!;
print "Starting records iteration\n" if $verbose;
## iterate through our marc files and do stuff
while (my $record = $batch->next()) {
## print the title contained in the record
print "\n########################################\n" if $verbose;
print $record->title(), "\n" if $verbose;
if ( $vendor eq '' ) {
print "Using rules for MPL.\n" if $verbose;
copy_field( $record, '092', 'a', '952', 'c' ) or die("Couldn't copy 092a to 952c");
copy_field( $record, '092', 'a', '952', 'k' ) or die("Couldn't copy 092a to 952k");
copy_field( $record, '092', 'a', '942', 'j' ) or die("Couldn't copy 092a to 942j");
copy_field( $record, '092', 'a', '942', 'k' ) or die("Couldn't copy 092a to 942k");
copy_field( $record, '092', 'a', '952', 'l' ) or die("Couldn't copy 092a to 952l");
if ( ! field_exists( $record, '020', 'c' ) ) {
print "020c is empty, creating it with value of 0.\n" if $verbose;
update_field( $record, '020', 'c', '0' ) or die("Couldn't update 020c.");
} else {
my $field_020c = read_field( $record, '020', 'c' );
print "020c was $field_020c\n" if $verbose;
$field_020c =~ s/\$//; ## Removes the '$' from the field, shouldn't be there.
update_field( $record, '020', 'c', $field_020c ) or die("Couldn't update 020c");
print "020c is now $field_020c\n" if $verbose;
}
copy_field( $record, '020', 'c', '952', '9' ) or die("Couldn't copy 020c to 952 9");
copy_field( $record, '020', 'c', '952', 'r' ) or die("Couldn't copy 020c to 952r");
update_field( $record, '952', 'b', $branchcode ) or die("Couldn't update 952b to $branchcode");
update_field( $record, '952', 'd', $branchcode ) or die("Couldn't update 952d to $branchcode");
#barcode
copy_field( $record, '901', 'a', '952', 'p' ) or die("Couldn't copy 901a to 952p");
print "Barcode: " . read_field($record , '901', 'a') . "\n";
## Put today's date into 952v, 952w in format yyyy-mm-dd
my $date = getToday();
print "Today's date in formt yyyy-mm-dd: ", $date, "\n" if $verbose;
update_field( $record, '952', 'v', $date ) or die("Couldn't update 952v to $date");
update_field( $record, '952', 'w', $date ) or die("Couldn't update 952w to $date");
## Get the item type by the syntax of the call number, put item type in 942c & 942d
my $field_092a = read_field( $record, '092', 'a' );
my $itemtype = get_item_type( $branchcode, $field_092a );
print "Branch code: ", $branchcode, "\n" if $verbose;
print "Call number: ", $field_092a, "\nItem type: ", $itemtype, "\n" if $verbose;
update_field( $record, '942', 'c', $itemtype ) or die("Couldn't update 942c to $itemtype");
update_field( $record, '942', 'd', $itemtype ) or die("Couldn't update 942d to $itemtype");
} elsif ( $vendor eq 'BakerTaylor' ) {
print "Using rules for ", $branchcode, "with BakerTaylor files.\n" if $verbose;
## Call Number
if ( ! field_exists( $record, '852', 'h' ) ) {
update_field( $record, '852', 'h', 'Default' );
}
copy_field( $record, '852', 'h', '952', 'c' ) or die("Couldn't copy 852h to 952c");
copy_field( $record, '852', 'h', '952', 'k' ) or die("Couldn't copy 852h to 952k");
copy_field( $record, '852', 'h', '942', 'j' ) or die("Couldn't copy 852h to 942j");
copy_field( $record, '852', 'h', '942', 'k' ) or die("Couldn't copy 852h to 942k");
copy_field( $record, '852', 'h', '952', 'l' ) or die("Couldn't copy 852h to 952l");
print "Call number: " . read_field($record , '852', 'h') . "\n";
## Price
if ( ! field_exists( $record, '020', 'c' ) ) {
print "020c (Price) is empty, creating it with value of 0." if $verbose;
update_field( $record, '020', 'c', '0' ) or die("Couldn't update 020c to value of 0.");
} else {
my $field_020c = read_field( $record, '020', 'c' );
print "020c was $field_020c\n" if $verbose;
$field_020c =~ s/\$//; ## Removes the '$' from the field, it shouldn't be there.
update_field( $record, '020', 'c', $field_020c ) or die("Couldn't update 020c");
print "020c is now $field_020c\n" if $verbose;
}
copy_field( $record, '020', 'c', '952', '9' ) or die("Couldn't copy 020c to 952 9");
copy_field( $record, '020', 'c', '952', 'r' ) or die("Couldn't copy 020c to 952r");
## Branchcode
update_field( $record, '952', 'b', $branchcode ) or die("Couldn't update 952b to $branchcode");
update_field( $record, '952', 'd', $branchcode ) or die("Couldn't update 952d to $branchcode");
## Barcode
copy_field( $record, '852', 'p', '952', 'p' ) or die("Couldn't copy 852p to 952p");
print "Barcode: " . read_field($record , '852', 'p') . "\n";
## Put today's date into 952v, 952w in format yyyy-mm-dd
my $date = getToday();
print "Today's date in format yyyy-mm-dd: ", $date, "\n" if $verbose;
update_field( $record, '952', 'v', $date ) or die("Couldn't update 952v to $date");
update_field( $record, '952', 'w', $date ) or die("Couldn't update 952w to $date");
## Get the item type by the syntax of the call number, put item type in 942c & 942d
my $field_852h = read_field( $record, '852', 'h' );
my $itemtype = get_item_type( $branchcode, $field_852h );
print "Branch code: ", $branchcode, "\n" if $verbose;
print "Item Type: " . $itemtype . "\n" if $verbose;
update_field( $record, '942', 'c', $itemtype ) or die("Couldn't update 942c to $itemtype");
update_field( $record, '942', 'd', $itemtype ) or die("Couldn't update 942d to $itemtype");
} elsif ( $branchcode eq "SAEG" && $vendor eq 'SmartAppleMedia' ) {
print "Using rules for SAEG with SmartAppleMedia files.\n" if $verbose;
## Call Number
if ( ! field_exists( $record, '092', 'a' ) ) {
update_field( $record, '092', 'a', 'Default' );
}
copy_field( $record, '092', 'a', '952', 'c' ) or die("Couldn't copy 092a to 952c");
copy_field( $record, '092', 'a', '952', 'k' ) or die("Couldn't copy 092a to 952k");
copy_field( $record, '092', 'a', '942', 'j' ) or die("Couldn't copy 092a to 942j");
copy_field( $record, '092', 'a', '942', 'k' ) or die("Couldn't copy 092a to 942k");
copy_field( $record, '092', 'a', '952', 'l' ) or die("Couldn't copy 092a to 952l");
print "Call number: " . read_field($record , '092', 'a') . "\n";
## Price
if ( ! field_exists( $record, '852', '9' ) ) {
print "852 9 (Price) is empty, creating it with value of 0." if $verbose;
update_field( $record, '852', '9', '0' ) or die("Couldn't update 952 9 to value of 0.");
} else {
my $field_852_9 = read_field( $record, '852', '9' );
print "852 9 was $field_852_9\n" if $verbose;
$field_852_9 =~ s/\$//; ## Removes the '$' from the field, it shouldn't be there.
update_field( $record, '852', '9', $field_852_9 ) or die("Couldn't update 952 9");
print "852 9 is now $field_852_9\n" if $verbose;
}
copy_field( $record, '852', '9', '952', 'r' ) or die("Couldn't copy 952 9 to 952r");
copy_field( $record, '852', '9', '952', '9' ) or die("Couldn't copy 852 9 to 952 9");
## Branchcode
update_field( $record, '952', 'b', $branchcode ) or die("Couldn't update 952b to $branchcode");
update_field( $record, '952', 'd', $branchcode ) or die("Couldn't update 952d to $branchcode");
## Put today's date into 952v, 952w in format yyyy-mm-dd
my $date = getToday();
print "Today's date in format yyyy-mm-dd: ", $date, "\n" if $verbose;
update_field( $record, '952', 'v', $date ) or die("Couldn't update 952v to $date");
update_field( $record, '952', 'w', $date ) or die("Couldn't update 952w to $date");
## Barcode
copy_field( $record, '852', 'p', '952', 'p' ) or die("Couldn't copy 852p to 952p");
print "Barcode: " . read_field($record , '852', 'p') . "\n";
## Get the item type by the syntax of the call number, put item type in 942c & 942d
my $field_092a = read_field( $record, '092', 'a' );
my $itemtype = get_item_type( $branchcode, $field_092a );
print "Branch code: ", $branchcode, "\n" if $verbose;
print "Item Type: " . $itemtype . "\n" if $verbose;
update_field( $record, '942', 'c', $itemtype ) or die("Couldn't update 942c to $itemtype");
update_field( $record, '942', 'd', $itemtype ) or die("Couldn't update 942d to $itemtype");
}
print "########################################\n";
## we're done with this record, write it to file and move on...
print OUT $record->as_usmarc();
}
print "End of records\n" if $verbose;
## make sure there weren't any problems
if ( my @warnings = $batch->warnings() ) {
print "\nWarnings were detected!\n", @warnings;
}
sub get_item_type {
my ( $branchcode, $callnumber ) = @_;
if ( $branchcode eq 'MPL' ) {
if ( $callnumber =~ /^[0-9]/ ) { return 'NF'; }
if ( $callnumber =~ /^JR |JREF |JUV REF / ) { return 'JREF'; }
if ( $callnumber =~ /^JUV [0-9]/ ) { return 'JNF'; }
if ( $callnumber =~ /^JUV BOC / ) { return 'JBOC'; }
if ( $callnumber =~ /^JUV E |JUV ER |JUV BOARD BOOK/ ) { return 'EASY'; }
if ( $callnumber =~ /^JUV FIC / ) { return 'JFIC'; }
if ( $callnumber =~ /^JUV PB / ) { return 'JPB'; }
if ( $callnumber =~ /^JUV (CASSETTE|CS) / ) { return 'JCAS'; }
if ( $callnumber =~ /^CCFLS J |CCFLS JUV |ECLS / ) { return 'JBOC'; }
if ( $callnumber =~ /^JUV BOOK BAG/ ) { return 'BB'; }
if ( $callnumber =~ /^JUV VCR |JVCR |jVCR / ) { return 'JVHS'; }
if ( $callnumber =~ /^TOY COLLECTION/ ) { return 'TOYS'; }
if ( $callnumber =~ /^JUV PERIODICAL/ ) { return 'JMAG'; }
if ( $callnumber =~ /^JHS |JUV HS |J HS/ ) { return 'JHS'; }
if ( $callnumber =~ /^JUV HS PERIODICAL/ ) { return 'JMAG'; }
if ( $callnumber =~ /^JUV VF / ) { return 'JPF'; }
if ( $callnumber =~ /^JUV P |JUV PARENTS COLLECTION / ) { return 'JPT'; }
if ( $callnumber =~ /^FIC LARGE PRINT |LP / ) { return 'LP'; }
if ( $callnumber =~ /^BOC |BOC FIC |FIC BOC |FIC BOOKS ON CASSETTE / ) { return 'BOC'; }
if ( $callnumber =~ /^VCR / ) { return 'VHS'; }
if ( $callnumber =~ /^PERIODICAL|STAFF PERIODICAL/ ) { return 'MAG'; }
if ( $callnumber =~ /^VF / ) { return 'PF'; }
if ( $callnumber =~ /^FIC D |FIC-D / ) { return 'DF'; }
if ( $callnumber =~ /^FIC R |FIC-R / ) { return 'RF'; }
if ( $callnumber =~ /^FIC SC |SC / ) { return 'SC'; }
if ( $callnumber =~ /^FIC SF |SF / ) { return 'SF'; }
if ( $callnumber =~ /^FIC W |FIC-W / ) { return 'W'; }
if ( $callnumber =~ /^FIC PBC |FIC-PBC |PB / ) { return 'PB'; }
if ( $callnumber =~ /^FIC PBC D |FIC PBC-D / ) { return 'PBCD'; }
if ( $callnumber =~ /^FIC PBC C |FIC PBC CLASSIC |FIC PBC-CLASSIC / ) { return 'PBCC'; }
if ( $callnumber =~ /^FIC PBC SF |FIC PBC-SF / ) { return 'PBSF'; }
if ( $callnumber =~ /^FIC PBC W |FIC PBC-W / ) { return 'PBCW'; }
if ( $callnumber =~ /^FIC PBC YA |FIC PBC-YA / ) { return 'YAPB'; }
if ( $callnumber =~ /^FIC YA / ) { return 'YAF'; }
if ( $callnumber =~ /^CASSETTE |CS / ) { return 'CAS'; }
if ( $callnumber =~ /^CD / ) { return 'CD'; }
if ( $callnumber =~ /^PB YA / ) { return 'YAPB'; }
if ( $callnumber =~ /^READ PROGRAM / ) { return 'VHS'; }
if ( $callnumber =~ /^COLLEGE / ) { return 'TEMP'; }
if ( $callnumber =~ /^CCFLS / ) { return 'BOC'; }
if ( $callnumber =~ /^FIC PERIODICAL|YA PERIODICAL/ ) { return 'MAG'; }
if ( $callnumber =~ /^OS / ) { return 'O'; }
if ( $callnumber =~ /^BCD |CCFLS BCD / ) { return 'BCD'; }
if ( $callnumber =~ /^JCCFLS CD / ) { return 'JBCD'; }
if ( $callnumber =~ /^JDVD |JUV DVD |jDVD / ) { return 'JDVD'; }
if ( $callnumber =~ /^JCD |JUV CD / ) { return 'JCD'; }
if ( $callnumber =~ /^JBCD |JUV BCD / ) { return 'JBCD'; }
if ( $callnumber =~ /^DVD / ) { return 'DVD'; }
if ( $callnumber =~ /^YA BOC / ) { return 'YBOC'; }
if ( $callnumber =~ /^YA BCD / ) { return 'YBCD'; }
if ( $callnumber =~ /^YA / ) { return 'YANF'; }
if ( $callnumber =~ /^FIC / ) { return 'FIC'; }
if ( $callnumber =~ /^MAGAZINE|NEWSPAPER/i) { return 'MAG'; }
if ( $callnumber =~ /^R STAF |REF STAFF |R |REF |REFERENCE / ) { return 'REF'; }
die("Cannot match callnumber $callnumber to any known item type");
} elsif ( $branchcode eq 'SAEG' ) {
if ( $callnumber eq 'Default' ) { return '1'; }
if ( $callnumber =~ /^B |920 /) { return 'BIO'; }
if ( $callnumber =~ /^J Cass|J Books on Cass|J CD /i) { return 'BB'; }
if ( $callnumber =~ /^AC J /) { return 'JBOC'; }
if ( ( $callnumber =~ /^AC F |AC FIC |AC / ) && !( $callnumber =~ /^AC J /) ) { return 'BOC'; }
if ( $callnumber =~ /^CD |CD F /) { return 'BCD'; }
if ( $callnumber =~ /^DVD /) { return 'DVD'; }
if ( $callnumber =~ /^FIC /) { return 'FIC'; }
if ( $callnumber =~ /^J B |J 920 |JB /) { return 'JBIO'; }
if ( $callnumber =~ /^J DVD /) { return 'JDVD'; }
if ( $callnumber =~ /^J FIC |J F /) { return 'JFIC'; }
if ( $callnumber =~ /^Juvenile Mag|Juv Mag/i) { return 'JMAG'; }
if ( $callnumber =~ /^J [0-9][0-9][0-9]+/) { return 'JNF'; }
if ( $callnumber =~ /^J PB /) { return 'JPB'; }
if ( $callnumber =~ /^J SC /) { return 'JSC'; }
if ( $callnumber =~ /^JUV VIDEO/i) { return 'JVHS'; }
if ( $callnumber =~ /^ADULT PERIODICAL|PERIODICAL|MAGAZINE/i) { return 'MAG'; }
if ( $callnumber =~ /^ADULT MUSIC CD/i) { return 'CD'; }
if ( $callnumber =~ /^[0-9][0-9][0-9]+/) { return 'NF'; }
if ( $callnumber =~ /^Vertical|Local Hist/i) { return 'PF'; }
if ( $callnumber =~ /^REF [0-9][0-9][0-9]+/) { return 'REF'; }
if ( $callnumber =~ /^SC /) { return 'SC'; }
if ( $callnumber =~ /^ADULT VIDEO/i) { return 'VHS'; }
if ( $callnumber =~ /^YA FIC |YA F /) { return 'YAF'; }
if ( $callnumber =~ /^YA PB/i) { return 'YAPB'; }
return '1';
print("Cannot match callnumber $callnumber to any known item type.") && die();
} elsif ( $branchcode eq 'BEN' ) {
if ( $callnumber eq 'Default' ) { return '1'; }
if ( $callnumber =~ /^PER|MAG/i) { return 'MAG'; }
return '1';
print("Cannot match callnumber $callnumber to any known item type.") && die();
} elsif ( $branchcode eq 'COCH' ) {
if ( $callnumber eq 'Default' ) { return '1'; }
if ( $callnumber =~ /^PER|MAG/i) { return 'MAG'; }
if ( $callnumber =~ /^F |FIC |FICTION |\[F /i) { return 'FIC'; }
if ( $callnumber =~ /^REF |REFERENCE |\[R /i) { return 'REF'; }
if ( $callnumber =~ /^92|B | BIO|\[B /i) { return 'BIO'; }
if ( $callnumber =~ /^E |EAS |\[E /i) { return 'EASY'; }
if ( $callnumber =~ /^[0-9][0-9][0-9]+/) { return 'NF'; }
if ( $callnumber =~ /^SC |STORY COLLECTION |\[SC /i) { return 'SC'; }
if ( $callnumber =~ /^J FIC/i) { return 'JFIC'; }
if ( $callnumber =~ /^J [0-9][0-9][0-9]+/) { return 'JNF'; }
if ( $callnumber =~ /^ADULT PERIODICAL|PERIODICAL|MAGAZINE/i) { return 'MAG'; }
return '1';
print("Cannot match callnumber $callnumber to any known item type.") && die();
} elsif ( $branchcode eq 'STON' ) {
if ( $callnumber eq 'Default' ) { return '1'; }
if ( $callnumber =~ /^PER|MAG|JUV PER/i) { return 'MAG'; }
if ( $callnumber =~ /^F |FIC |FICTION |\[F /i) { return 'FIC'; }
if ( $callnumber =~ /^REF |REFERENCE |\[R /i) { return 'REF'; }
if ( $callnumber =~ /^92|092|B | BIO|\[B /i) { return 'BIO'; }
if ( $callnumber =~ /^E |EAS |\[E /i) { return 'EASY'; }
if ( $callnumber =~ /^808|SC |STORY COLLECTION |\[SC /i) { return 'SC'; }
if ( $callnumber =~ /^[0-9][0-9][0-9]+/) { return 'NF'; }
if ( $callnumber =~ /^J [0-9][0-9][0-9]+/) { return 'JNF'; }
if ( $callnumber =~ /^J|\[J /i) { return 'JUV'; }
return '1';
print("Cannot match callnumber $callnumber to any known item type.") && die();
} elsif ( $branchcode eq 'LINE' ) {
if ( $callnumber eq 'Default' ) { return '1'; }
if ( $callnumber =~ /^PER|MAG/i) { return 'MAG'; }
if ( $callnumber =~ /^F |FIC |FICTION |\[F /i) { return 'FIC'; }
if ( $callnumber =~ /^REF |REFERENCE |\[R /i) { return 'REF'; }
if ( $callnumber =~ /^92|B | BIO|\[B /i) { return 'BIO'; }
if ( $callnumber =~ /^E |EAS |\[E /i) { return 'EASY'; }
if ( $callnumber =~ /^808|SC |STORY COLLECTION |\[SC /i) { return 'SC'; }
if ( $callnumber =~ /^[0-9][0-9][0-9]+/) { return 'NF'; }
if ( $callnumber =~ /^J [0-9][0-9][0-9]+/) { return 'JNF'; }
if ( $callnumber =~ /^J|\[J /i) { return 'JUV'; }
return '1';
print("Cannot match callnumber $callnumber to any known item type.") && die();
}
}
sub get_options {
my $input_file = '';
my $output_file = '';
my $marc_standard = '';
my $verbose = '';
my $branchcode = '';
my $help = '';
my $microlif = '';
GetOptions("i|infile=s"=>\$input_file,
"o|outfile=s"=>\$output_file,
"t|m|marctype=s"=>\$marc_standard,
"v|verbose!"=> \$verbose,
"b|branchcode=s"=> \$branchcode,
"c|company|vendor=s" => \$vendor,
'h|?|help' => \$help
);
pod2usage(-exitval => 0) if $help;
pod2usage( -msg => "\nMissing Argument: -i, --infile required\n", -exitval => 1) if !$input_file;
pod2usage( -msg => "\nMissing Argument: -o, --outfile required\n", -exitval => 1) if !$output_file;
pod2usage( -msg => "\nMissing Argument: -b, --branchcode required\n", -exitval => 1) if !$branchcode;
pod2usage( -msg => "\nMissing Argument: -t ,-m , --marctype required\n", -exitval => 1) if !$marc_standard;
return ($input_file, $output_file, $marc_standard, $verbose, $branchcode, $vendor);
}
sub getToday {
my ($day, $month, $year) = (localtime())[3..5];
$month++;
if ( int $month < 10 ) { $month = '0' . $month; }
if ( int $day < 10 ) { $day = '0' . $day; }
$year += 1900;
my $date = $year . '-' . $month . '-' . $day;
return $date;
}
__END__
=head1 NAME
updateMarcForKoha.pl - Scans a MARC file and fixes a number of fields for Koha.
=head1 SYNOPSIS
updateMarcForKoha.pl -i inputfile -o outputfile -b branchcode -t marctype [-v] [-h]
=head1 OPTIONS
=over 8
=item B<-i, --infile>
Name of the MARC file to be read.
=item B<-o, --outfile>
Name of the file to write the fixed MARC data to.
=item B<-b, --branchcode>
Branchcode of the library from Koha
=item B<-t, -m, --marctype>
Specifies which MARC Standard is to be used (i.e. MARC21, USMARC, UNIMARC )
=item B<-v, --verbose>
Details of the process will be printed to stdout
=item B<-h, -?, --help>
Prints this help message and exits.
=back
=cut