Altering creation dates in image exif data

Whilst attempting to get a Kodak digital photo frame to display the photos in the correct order, I worked out how to set the creation dates to a sequential order (don’t ask).

First, install ExifTool.

Then run something like this (copy it to a file, e.g., then run whilst in a directory of files to alter):

for i in *; do
	touch i
	new=$(printf "%04d.jpg" ${a}) #04 pad to length of 4
	if [ "${i}" != "${new}" ]; then
		mv ${i} ${new}

	minutes=$(( $a * 60 ))

	timeString=$(echo $minutes | awk '{printf("%s", strftime("%H:%M:%S", $1));}';)
	exiftool "-FileModifyDate=2012:03:09 $timeString" \
	"-ModifyDate=2012:03:09 $timeString" \
	"-DateTimeOriginal=2012:03:09 $timeString" \
	"-CreateDate=2012:03:09 $timeString" \
	"-DateTimeDigitized=2012:03:09 $timeString" \
	"-MetadataDate=2012:03:09 $timeString" ${new}

	let a=a+1

It was more complicated than it should have been, and I think there may be a bug somewhere in it.

The code just sets the time of the various dates in the exif data to a value based on the file number.  It also names the files in a sequential order.

Leave a Reply

Your email address will not be published. Required fields are marked *