LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Blogs > peonuser
User Name
Password

Notices


Rate this Entry

Pictures to html

Posted 11-19-2014 at 06:21 AM by peonuser

Generate a web page three pics wide from a directory of pictures.

#!/bin/bash
# daffinitions
ls *.png > picdatafile
#ls *.jpg >> picdatafile
#ls *.JPG >> picdatafile
datafile="picdatafile"
htmlfile="test.html"
a=1
m="not done"
d=" "

#read the file
while read line
do fdata[$a]=$line
let a=a+1
done < $datafile
a=$a-1
# top
echo "<html>" > $htmlfile
echo "<body>" >> $htmlfile
echo "<h2><center>Picture list</center></h2>" >> $htmlfile
echo "<hr>" >> $htmlfile

echo "<center>" >> $htmlfile
echo "<table border="10">" >> $htmlfile


# middle
for (( COUNTER=1; COUNTER<=$a; COUNTER+=3 )); do
echo "<tr>" >> $htmlfile
for i in `seq 0 2`;
do
echo "<td>" >> $htmlfile
d=`echo ${fdata[$i+$COUNTER]} | sed 's/\([^\.]*\)\..*/\1/'`
theline='<img src="'${fdata[$i+$COUNTER]}'" alt="'${d}'" width="300" height="300" hspace="20" vspace="20">'
echo "$theline" >> $htmlfile
echo "</td>" >> $htmlfile
done
echo "</tr>" >> $htmlfile
echo "<br />" >> $htmlfile
done

echo "</table>" >> $htmlfile
echo "</center>" >> $htmlfile

# bottom
echo "</body>" >> $htmlfile
echo "</html>" >> $htmlfile
Posted in Uncategorized
Views 1275 Comments 0
« Prev     Main     Next »
Total Comments 0

Comments

 

  



All times are GMT -5. The time now is 02:24 AM.

Main Menu
Advertisement
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration