#!/bin/sh

# giving the files the times as contained originally within their body,
# but with a subsequent correction

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

mkdir d

for F in *.jpg 
do 
sed -n "/2001/{s/2001//; s/[: ]//g; s/[[:cntrl:]]/ /g ; s/.. 2001.*// ; s/ //g ; \
    s/\(.\{4\}\)\(.\{2\}\)\(.\{2\}\)/\1 \2:\3 1 day 16 hour 27 min\"/ ; 
    s/^/touch -d \"2001/; \
    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
