eval { require "$FindBin::Bin/../kohalib.pl" };
}
+use Koha::Script;
+
use Getopt::Long;
use Pod::Usage;
use MARC::Field;
'unless-exists=s' => \$unless_exists_field,
) || podusage(1);
-pod2usage(0) if $help;
+pod2usage(1) if $help;
+pod2usage("Parameter field is mandatory") unless @fields;
my @fields_to_add;
my $dt = dt_from_string; # Could be an option of the script
say "\t" . $_->as_formatted for @fields_to_add;
}
-$where ||= "";
+$where = $where ? "WHERE $where" : '';
my $sth =
$dbh->prepare("SELECT biblionumber, frameworkcode FROM biblio $where");
$sth->execute();
perl add_date_fields_to_marc_records.pl --field='905$a=0/%Y' --field='905$a=1/%Y/%b-%m' --field='905$a=2/%Y/%b-%m/%d' --unless-exists='905$a' --verbose --confirm
+ perl add_date_fields_to_marc_records.pl --field='905$a=0/%Y' --field='905$a=1/%Y/%b-%m' --field='905$a=2/%Y/%b-%m/%d' --unless-exists='905$a' --where "biblionumber=42" --verbose --confirm
+
=head1 DESCRIPTION
Add some MARC fields to bibliographic records.
The replacement tokens are the ones used by strftime.
+=head1 OPTIONS
+
=over 8
=item B<--help>
=item B<--confirm>
Confirmation flag, the script will be running in dry-run mode if set not.
+
=item B<--where>
Limits the search on bibliographic records with a user-specified WHERE clause.
+Only the columns from the biblio table are available.
+
=item B<--field>
Fields to add to the bibliographic records.
=item B<--unless-exists>
-Will only create the new fields if this field does not exist
+Will only create the new fields if this field does not exist.
+
+For instance, if --field='905$a=0/%Y' and --unless-exists='905$a' are provided, a 905$a will be created unless there is already one.
+If --unless-exists is not passed, a new 905$a will be created in any case.
+
=back