#!/bin/sh

# giving the files the times as contained originally within their body

if [ -e d ]
then
 echo The directory d exists already, quitting
 exit
fi 

mkdir d

for F in *.jpg 
do 
sed -n "/2002/{s/2002//; s/[: ]//g; s/[[:cntrl:]]/ /g ; s/.. 2002.*// ; s/ //g ; \
    s/^/touch -t /; s/$/ ..\/$F/p ; q;}" $F >d/$F 
done

cd d

for F in *.jpg 
do chmod +x $F ; ./$F ; rm $F
done

cd ..
rmdir d
