try generate a foo5.html which has not only the images, but also links to each of the originals: <a href=image1.jpg><img src=image1.jpg.s.jpg></a><br>. Actually, it might be better to start with the large images, "ls -1 *jpg | grep -v 's.jpg'". Then use sed to create something like <a href=image1.jpg><img src=image1.jpg.></a><br>. Then add the s.jpg to the suffix of the files that are used in the img tags. Ha ha ha ha. That's going to be a real challenge for almost anyone. But with the right combination of sed commands, you should be able to do it.