#!/bin/sh
photodir="stream"
galleryfile="index.html"
bfile="$(sed '//q' $galleryfile )"
efile="$(sed '1,//d' $galleryfile )"
perfour() {
# One out of every five lines:
batch="$(awk 'NR == 1 || NR % 5 == 0' - )"
# Add the html fluff:
list="$(
for i in $batch; do
base="$(echo "$i" | cut -f 1 -d "." )"
printf "\t\t\n"
done
)"
printf "\t
\n$list\n\t
"
}
all="$(ls -t $photodir)"
col1="$(echo "$all" | perfour)"
all="$(echo "$all" | sed '1d' )"
col2="$(echo "$all" | perfour)"
all="$(echo "$all" | sed '1d' )"
col3="$(echo "$all" | perfour)"
all="$(echo "$all" | sed '1d' )"
col4="$(echo "$all" | perfour)"
gallery="$(printf "\n$col1\n$col2\n$col3\n$col4\n
\n\n")"
echo "$bfile
$gallery
$efile" > index.html