#! /bin/bash -e
# Last edited on 2025-07-13 16:55:46 by stolfi

beg="$1"; shift
end="$1"; shift

tmp="/tmp/$$"

flist="${tmp}-list.txt"
cat clip-list.txt \
  | gawk -v beg=${beg} -v end=${end} \
      ' BEGIN { beg += 0; end += 0; }
        /^[|]/{ 
          bw = $2 + 0; 
          if ((bw >= beg) && (bw <= end)) { print $9; }
        }
      ' \
  > ${flist}
  
for f in `cat ${flist}` ; do 
  imgfile="FromBeinecke/${f}.jpg"
  echo "${imgfile}" 1>&2
  if [[ -s ${imgfile} ]]; then
    gimp -s -n ${imgfile}
  else
    echo "** ${imgfile} not found" 1>&2; exit 1
  fi
done
