[EP-tech] ChatGPT

Christopher Gutteridge totl at soton.ac.uk
Sun Jan 8 18:25:37 GMT 2023


So, it seems that EPrints is well documented enough online that ChatGPT 
can write simple EPrints scripts and functions. I'm frankly astounded at 
what this tool can do. It can't do complex stuff but it's still impressive.



Christopher Gutteridge
PROMPT:
please suggest a perl script to operate on an EPrints repository. It 
should find all the records with no title and set the title to "NO TITLE".


#!/usr/bin/perl

use EPrints;


  Initialize the repository

my $repo = EPrints->new->repository('your_repository_id');


  Find all records with no title

my $records = $repo->search({ match => 'AND', filters => [ { meta_fields 
=> [ 'title' ], value => '', match => 'EQ' }, ], });


  Set the title of each record to "NO TITLE"

foreach my $record ($records->get_records) {

$record->set_value('title', 'NO TITLE');

$record->commit;

}

print "Finished setting titles of records with no title to 'NO TITLE'\n";

-- 
Christopher Gutteridge, Research Application Support, University of Southampton
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ecs.soton.ac.uk/pipermail/eprints-tech/attachments/20230108/decac889/attachment.html 


More information about the Eprints-tech mailing list