#! /bin/tcsh -f ###################################################################### # # Finds the PDF files on the website and assembles a list of 'em set me=${0:t} # name of this script goto Start ###################################################################### Usage: cat << END_INPUT usage: $me:t Assembles a nicely formatted HTML file with a list of PDF files on the website. END_INPUT exit ###################################################################### Start: if ( ($# >= 1) ) then goto Usage endif # Abort if the required env variables aren't set if (! ${?HTML_DIR}) then echo ${me}: HTML_DIR environment variable not set\! exit endif set homeDir = ${HTML_DIR} set resultFile = $homeDir/tech/download/pdf-list.html set pathToRoot = "../.." # the path to $HTML_DIR from the resultFile set tmpFile_0 = ~/tmp/${me}.tmpFile_0 if (! -e $resultFile) then echo ${me}: "Can't find file '$resultFile'\!" echo Goodbye. exit endif echo -n "${me}: building list of PDF files..." # delete the old chunk from the file ed -s $resultFile << END_INPUT //,// d i . w Q END_INPUT cat << END_INPUT > $tmpFile_0 END_INPUT cd $homeDir set thePDF_List = `find . -name \*.pdf -print` set noErr set nTally=0 foreach PDF_file ($thePDF_List) # suppose PDF_file = a/b/foo/bar.pdf set PDF_root = $PDF_file:r # = a/b/foo/bar set HTML_file = ${PDF_root}.html # = a/b/foo/bar.html set INDEX_file = ${HTML_file:h}/index.html # = a/b/foo/index.html set PDF_tail = $PDF_file:t # = bar.pdf set theAnchor = "${INDEX_file}#$PDF_tail:r" if (! -e $HTML_file) then #if the HTML (bar.html) doesn't exist, then try bar/index.html set HTML_file = `echo $HTML_file | sed -e "s/\.html/\/index.html/"` if (! -e $HTML_file) then if (${?noErr}) then unset noErr echo ; endif echo " ***Skipping $PDF_file (can't find its associated HTML file)." continue endif endif @ nTally ++ getHdrForPDF.pl $HTML_file $PDF_file $theAnchor $pathToRoot >> $tmpFile_0 end # That's all for the table echo "
" >> $tmpFile_0 #insert the new chunk into the files ed -s $resultFile << END_INPUT > /dev/null / .r $tmpFile_0 w Q END_INPUT /bin/rm $tmpFile_0 if (${?noErr}) then echo " Found $nTally PDF files. Done." else echo "${me}: Found $nTally PDF files. Done." endif