Last active
December 20, 2015 01:59
-
-
Save silviopaganini/6052800 to your computer and use it in GitHub Desktop.
Generate HTML files from images for clickthrough presentation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# clean up any old HTML | |
for a in `ls -a *.html` | |
do | |
rm $a | |
done | |
# create array with the images | |
array=( $( ls -a *.png *.jpg ) ) | |
len=${#array[*]} | |
for (( i=0; i<$len; i++ )) | |
do | |
b=`expr $i + 1` | |
if (($b==$len)); then | |
b="0" | |
fi | |
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\"><html><head><style type=\"text/css\">body {padding:0px; margin:0px;}img {border:0px; display: block; margin-left: auto; margin-right: auto;}</style><title>$i</title></head><body><a href=\"$b.html\"><img src=\"images/${array[$i]}\"></a></body></html>" > $i.html | |
done | |
# move images to a different folder | |
mkdir images | |
for i in `ls -a *.png *.jpg` | |
do | |
mv $i images/ | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment