#!/usr/bin/perl use File::Copy; use Shell::Command; use Time::Local; # relocate_audio # modified version of relocate_all for audio # picks up jpegs of transcripts from jpegs directory # ocr of those from ocr directory # MODS from MODS directory # mp3s from mp3 directory. # this version simply scatters them to where they go in # the web-accessible directories, so his software can work with them. # jody DeRidder, 1/29/10 ## Copyright (c) 2010, The University of Alabama Libraries. ## Contributed by Jody DeRidder, 7/30/10. ## All rights reserved. ## Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: ## * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. ## * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in ## the documentation and/or other materials provided with the distribution. ## * Neither the name of The University of Alabama Libraries nor the names of its contributors may be used to endorse or promote products ## derived from this software without specific prior written permission. ##THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, ##THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR ##CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, ##PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF ##LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, ##EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. $modsdir = "../MODS/"; $jpegdir = "../jpegs/"; $ocrdir = "../ocr/"; $mp3dir = "../mp3/"; $outbase = "/srv/www/htdocs/content/"; print "\n\nPlease place the content in the appropriate directories under AUDIO;\nno subdirectories are needed.\n"; print "Unzip them, make sure they are all on the same level, \nno subdirectories for compound objects.\n\n"; print "\nWARNING: This script assumes all jpegs, ocr.txt and txt files are Transcripts.\n\n"; print "Remove extraneous files, including the Admin xml file! That must be uploaded via Jody.\n"; print "\n When ready hit enter:\n"; $ans = ; @indirs = ($modsdir, $jpegdir, $ocrdir, $mp3dir); foreach $indir (@indirs){ `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 if ($file =~ /^(.{21}).*/){ $id = $1; } else{ print "ERROR: cannot find id for $file\n"; next;} ($mydir = $file) =~ s,\_,\/,g; # translate underscores in filename to / for directory path $mydir =~ s,\.mods\.xml,\/Metadata\/,; #remove extensions $mydir =~ s,\.mp3,\/,i; $mydir =~ s,\.ocr\.txt,\/Transcripts\/,i,; $mydir =~ s,\.txt,\/Transcripts\/,i,; $mydir =~ s,\/128\.jpg,\/Transcripts\/,i,; $mydir =~ s,\/512\.jpg,\/Transcripts\/,i,; $mydir =~ s,\/2048\.jpg,\/Transcripts\/,i,; $mydir = $outbase.$mydir; if (! -e $mydir){ $mypath = $mydir; $mypath =~ s,$outbase,,; undef $test; while ($mypath =~ /(.*?\/)(.*)/){ $test .= $1; $mypath = $2; $apath = $outbase.$test; if (!-e $apath){ `mkdir -m 0775 $apath`; } } $test .= $mypath; $apath = $outbase.$test; if (!-e $apath){ `mkdir -m 0775 $apath`; } } $oldfile = $indir."/".$file; $newfile = $mydir.$file; if (! (cp $oldfile, $newfile)){ print "ERROR: could not copy $oldfile to $newfile\n";} if (-e $newfile){ unlink $oldfile;} # deletes local copy } close(IN); } #`chmod -R 775 $outbase`; print "\nThank you! All done. \nPlease check directories; any files remaining\n"; print "were not processed and have a problem. Please correct and rerun.\n"; print "\n You can view the online 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;