#! /bin/csh -f
# Last edited on 2003-09-13 20:42:06 by stolfi

# Given a list of image names, if "foo.xxx" appears, removes
# "foo{-,_}{icon,thumb}.{xxx,png,gif,jpg}"

set tmp = "/tmp/$$"
set tmpa = "${tmp}-a"
set tmpb = "${tmp}-b"

cat | sort -u > ${tmpa}
cat ${tmpa} \
| sed \
    -e 's:^\(.*\)\.\([^.]*\)$:(\1_)(\2);(\1-)(\2):g' \
    -e 's:(\([^()]*\))(\([^()]*\)):(\1icon)(\2);(\1thumb)(\2):g' \
    -e 's:(\([^()]*\))(\([^()]*\)):\1.\2;\1.png;\1.gif;\1.jpg:g' \
| tr ';' '\012' \
| sort -u \
| bool 1-2 ${tmpa} -
