#! /bin/bash
# Last edited on 2023-01-17 19:58:28 by stolfi

# Summarizes the status of the texture bank.

# ".all-images" are all the images except those in JUNK directories.
find ./ \( -name '*.ppm' -o -name '*.pgm' -o -name '*.png' -o -name '*.jpg' -o -name '*.JPG' -o -name '*.tiff' \) -print \
  | grep -v -e 'JUNK/' \
  | sed -e 's:^[.]/::g' \
  | sort \
  > .all-images
  
# ".exported" are those in the standard exported directories like "ppm-400x400" and "pgm-512x512":
cat .all-images \
  | egrep -e '^(ppm-400x400|pgm-(512x512|256x256|128x128))/' \
  > .exported

# ".processed-in" are the images listed on the left side of {process_raw_files.sh}:
cat process_raw_files.sh \
  | sed -e 's:^[# ]*::g' \
  | egrep -e '^conv_' \
  | gawk '//{ printf "ls %s/%s.*\n", $2, $3; }' \
  > .tmp1
source .tmp1 | sort | uniq > .processed-in

# ".processed-out" are the images listed on the right side of {process_raw_files.sh}:
cat process_raw_files.sh \
  | sed -e 's:^[# ]*::g' \
  | egrep -e '^conv_' \
  | gawk '//{ printf "ls %s/%s.*\n", $7, $3; }' \
  > .tmp2
source .tmp2 | sort | uniq > .processed-out

# ".missing" are files that should have been processed but are not in the export directories:
bool 1-2 .processed-out .exported \
  | grep -v -e 'JUNK/' \
  > .missing
if [[ -s .missing ]]; then
  echo "*** missing files:" 1>&2
  cat .missing 1>&2
  echo "===" 1>&2
fi

# ".to-process" are files that look like they need processing:
bool 1-2 .all-images .exported > .to-process
