#! /bin/bash
# Last edited on 2022-08-04 08:52:42 by stolfi

# Finds images in a directory of ~/Downloads/ that are duplicated 
# in some directory with sorted files.

dirb="$1"

picsubs=( \
  Animals \
  Araraquara2017Neuro \
  Compras \
  Food \
  FortalezaConcurso2017 \
  Fun \
  IC_UFF \
  Indiana_2017 \
  Joao_Pessoa \
  LafayetteIN2016 \
  LuizVelho60Anos \
  Microscope \
  Misc \
  NIC.BR_Course_2017 \
  NeuromatRibPreto \
  NeuromatSampa2017 \
  NewYork2016 \
  Oficina \
  Plantas \
  Provas_UNICAMP \
  Quimica \
  Rhodes_ICNAAM_2016 \
  Stolfis \
  Texturas \
  TreeCruelty \
  Unicamp \
)

tag="X"
if [[ ! ( -d ${dirb} ) ]]; then
  echo "** '${dirb}' not found or not dir"
else
  ( cd Downloads/samsung-galaxy4/Camera && ls ) > .xxx
  ( 
  for s in ${picsubs[@]} ; do
    dira="Downloads/samsung-galaxy4/Pictures/${s}"
    if [[ ! ( -d ${dira} ) ]]; then
      echo "** '${dira}' not found or not dir"
    else
      ( cd ${dira} && ls ) >> .xxx
    fi
  done
  cat .xxx | sort | uniq > .aaa-${tag}
  echo "=== ~/${dirb} ==="
  ( cd ${dirb} && ls ) | sort > .bbb-${tag}
  bool 1.2 .aaa-${tag} .bbb-${tag} > .dup-${tag}
  wc -l .aaa-${tag} .bbb-${tag} .dup-${tag}
fi
