4 delete_images.pl - a script to hard delete images from a CXGN database.
8 perl delete_images.pl -h <dbhost> -d <dbname> -i <image_dir> file_with_image_ids
12 Be careful with this script! Ids have to match the given database etc etc
16 Lukas Mueller <lam87@cornell.edu>
22 use File
::Slurp qw
| slurp
|;
26 use CXGN
::DB
::InsertDBH
;
28 our ($opt_h, $opt_d, $opt_i, $opt_t);
32 my $dbh = CXGN
::DB
::InsertDBH
->new( {
39 my $image_id_file = shift;
41 my @image_ids = slurp
($image_id_file);
44 print STDERR
"Note: -t. Test mode. Will rollback after operations are done.\n";
47 my $deleted_image_count = 0;
51 foreach my $id (@image_ids) {
52 my $image = CXGN
::Image
->new(dbh
=>$dbh, image_id
=>$id, image_dir
=> $opt_i);
54 print STDERR
"Deleting image with id $id... (".$image->get_description().") ";
56 $image->hard_delete($opt_t);
57 print STDERR
"Done.\n";
60 $deleted_image_count++;
64 print STDERR
" -t option (test mode): rolling back...";
66 print STDERR
"Done.\n";
70 print STDERR
"An unfortunate error occurred... ($@)";
74 print STDERR
"Committing...\n";
78 print STDERR
"Deleted $deleted_image_count images. Done.\n";