#!/usr/bin/perl use File::Copy; use Shell::Command; # relocate_all # modified to move PDFs as well as MODS, 10/30/09, jld. # undergrad research does not need to be archived -- can be deposited in Acumen. # this for the MODS files output from spreadsheets using Tonio's software. # this version simply scatters them to where they go in # the web-accessible directories, so his software can work with them. # jody DeRidder, 8/20/09 $base = "./MODS/"; print "Please place the MODS and PDF files into a \nsubdirectory of MODS which is named for today's date.\n\n"; print "Unzip them, make sure they are all on the same level, \nno subdirectories for compound objects.\n\n"; print "Remove extraneous files. Then tell me the name of \ntoday's upload directory and hit enter:\n"; $dir = ; chomp $dir; $indir = $base.$dir; print "Is this correct? Enter Y or N\n"; $answ = ; while ($answ =~ /n/i){ REDO: print "Please re-enter the name of the subdirectory of MODS where you have today's upload:\n"; $dir = ; chomp $dir; $indir = $base.$dir; print "Is this correct? Enter Y or N\n"; $answ = ; } if (! -e $indir){ print "that directory does not exist.\n"; goto REDO; } else{ `chmod -R 775 $indir`;} # make sure we start with correct permissions, and then retain them $outbase = "/srv/www/htdocs/content/"; opendir(IN, $indir) or die "can't open $indir\n"; while ($file = readdir(IN)){ if ($file =~ /^\./){ next;} # skip . files # if (! $file =~ /\.mods\.xml$/){ next;} # skip -- uncomment this file if ALL we want to move are MODS files. ($mydir = $file) =~ s,\_,\/,g; # translate underscores in filename to / for directory path $mydir =~ s,\.mods\.xml,,; #remove extensions $mydir =~ s,\.pdf,,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";} } close(DIR); print "\nThank you! All done. \n You can view the files at http:\/\/libcontent1.lib.ua.edu\/content\/\n"; print "Log in at http:\/\/acumen.lib.ua.edu as admin with password:\n zero followed by letters \"fo\" followed by a one followed by the letter \"o\"\n click on Admin and reindex so that your changes will go live.\n"; print "\n Then please check the website to verify display is correct.\n"; print "\nHit enter to close this window.\n"; $ans = ; print "\n THANK YOU!!! Bye!!\n"; sleep(1); exit;