#!/usr/bin/perl use File::Copy; use Shell::Command; # makeItLive.pl # takes MODS, jpegs, and EAD from directories named as such within CABANISS # relocates them where they need to go in the web-accessible directories # this version for Cabaniss alone # copies the EAD, moves the MODS and jpegs # jody DeRidder, 12/11/09 $outbase = "/srv/www/htdocs/content/"; $modsDir = "../MODS/"; $jpegsDir = "../jpegs/"; $ead = "../EAD/u0003_0000252.ead.xml"; $eadloc = $outbase."u0003/0000252/Metadata/"; print "\n\nI am processing the MODS, then the JPEGs, and lastly, the EAD.\n"; print "Any errors will appear here! So watch...\n\n"; @moveme = ($modsDir, $jpegsDir); foreach $indir (@moveme){ `chmod -R 775 $indir`; # make sure we start with correct permissions, and then retain them opendir(IN, $indir) or die "can't open $indir\n"; while ($file = readdir(IN)){ if ($file =~ /^\./){ next;} # skip . files ($mydir = $file) =~ s,\_,\/,g; # translate underscores in filename to / for directory path $mydir =~ s,\.mods\.xml,,; #remove extensions $mydir =~ s,\.jpg,,i; if ($file =~ /\.mods\.xml$/){ $mydir = $outbase.$mydir."/Metadata/"; # goes in outbase directory, with Metadata subdirectory } else{ $mydir = $outbase.$mydir."/"; } if (! -e $mydir){ `mkdir -p $mydir`;} $oldfile = $indir."/".$file; $newfile = $mydir.$file; # if (! (cp $oldfile, $newfile)){ print "ERROR: could not copy $oldfile to $newfile\n";} # else{ unlink $oldfile;} # deletes local copy } close(IN); } #if (! (cp $ead, eadloc)){ print "ERROR: could not copy $ead to $eadloc\n";} print "\nThank you! All done. \nYou can view the files at http:\/\/libcontent1.lib.ua.edu\/content\/u0003\/0000252\/\n"; print "Then please check the website http://acumen.lib.ua.edu/u0003_0000252 to verify display is correct.\n"; print "\nHit enter to close this window.\n"; $ans = ; print "\n Bye!! Have a great day!!!\n\n"; sleep(1); exit;