#!/bin/bash ######################################################## # createwpimgeonly.sh # usage ./createwpimgeonly.sh # creates a webpage to display all the archived tunes # set pathtoarchive before running # written by Robin Newman August 2013 ######################################################## # adjust next three lines to suit archive location, webpage dir name and file name pathtoarchive=~/testarchive/ #end with trailing / wpdir=webimgpage #name of directory to hold finished webpage webpage=$wpdir/print.html #path to output web page in archive directory # you shouldn't have top make any changes after this line p=`pwd` #save starting directory cd $pathtoarchive #work in archive directory rm -R $wpdir 2>/dev/null #delete any existing wpdir, suppress error if none mkdir -p $wpdir/img #directory to hold preview images #now setup web page header info cat all info to it until EOFhtml reached cat > $webpage << EOFhtml
EOFhtml
for file in $( find -name *preview.png ) #enumerate the preview.png files
do #for each file found
#echo $file #uncomment for testing purposes
n=$(echo $file |sed -e 's/\.\///1' -e 's/\/.*//') #strip leading ./ and all after next /
#n holds date info for the file in format tone-yyyy-mm-dd-hh-mm-ss
#echo $n #uncomment for testing purposes
cp $file $wpdir/img/$n.png #copy and rename file into img directory
done
for file in $( ls $wpdir/img ) #enumerate files in img directory
do #for each file found
name=$(echo $file |sed -e 's/tone-//' -e 's/\..*//') #strip tone- and .png
# now format name as yyyy-mm-dd at hh:mm and ss seconds
name=$(echo $name |sed -e 's/-/ at /3' -e 's/-/:/3' -e 's/-/ and /3' -e 's/$/ seconds/')
#now build rest of web page
#insert title for tune and image link for each tune
echo processing tune for $name
cat >> $webpage <
EOFhtml
done
echo 'image only version of webpage finished!'
cd $p #switch back to starting directory
echo 'Present working directory'
pwd
##################### End of Script #######################