#!/bin/bash

# **************************************************************
#
# This script restores the original file time for picture files 
# based on the picture file name, which in turn is set using the
# exif information. The program jhead is used for this.
# 
# exiftool could be used to read the time and date directly from 
# the file. In that case the script would need to be changed.
#
# This script is licensed under GPL version 2 or any subsequent
# version at your choice.
# Copyright 2009 by Michael N. Steen
#
# Use at your own risk. There is no warrenty for anything at all
# except using space on your harddisk.
#
# **************************************************************

for f in "$@"
do
d=${f%-*}
t=${f#*-}
t=${t%_*}
hm=${t:0:4}
s=${t:4}
touch -t $d$hm.$s $f $f
done

