#!/bin/csh -f

if ($#argv < 2) then
    set shrink=30
    if ($#argv < 1) then
        echo "Usage: $0 <folder-name> <percent shrink>"
        exit 1
    endif
else 
    set shrink=$2    
endif

set photodir=/u/r/o/roundy/public/html/fotos/$1
echo "Resizing images in $photodir"

foreach thumb (`ls $photodir/thumbnails/*.jpg`)
  rm -f $thumb
end
cd $photodir
pwd
echo "$1" >> ../dirlist
mkdir thumbnails
foreach img (`ls *.jpg *.JPG`)
  convert $photodir/$img -resize $shrink% $photodir/thumbnails/$img
  echo "$img -> thumbnails/$img"
end

echo "done"

