Correcting Create date on a JPEG

Hi guys,

I recently received a lot of pictures from my sister’s new DSLR camera. After I saved the pictures, I noticed that she had the time set to PM instead of AM, and the day before the current date. This causes them to be out of order with other pictures taken at the same time with another camera and for archival purposes, i would like to have them all in chronological order.

I created a script to increment the creation date of the images by 12 hours so that it will correct the mistake, but I am having trouble getting the date into the correct format to send the touch command. If anyone could help, it would be greatly appreciated!


set theFile to (choose file)
tell application "Finder"
	set oldDate to creation date of theFile as date
	set newDate to (oldDate) + 12 * hours
	--set newTime to time string of (newDate)
end tell
display dialog "the current timestamp is: " & oldDate & ".  The new file will be changed to: " & newDate
do shell script "touch -t " & newDate & quoted form of POSIX path of theFile
-- return (info for theFile)


the touch command does not change the creation date, only the access and modification date.
It expects the date paramter in format [CC]YYMMDDhhmm[.SS], Century and Seconds are optional.
And there is a space character required before the file path

Well, if I cannot change the creation date, then i could change the modified date and sort the folder by date modified.

How do i get the date into the YYMMDDhhmm format? When i get the date from finder it puts it into a text format.

tell application “Finder”
get creation date of alias “Macintosh HD:Users:blah:test.jpg”
→ date “Tuesday, April 17, 2012 2:43:10 PM”
end tell

it might be easier to adjust the timestamp by a specified amount with the -A switch

touch -A 120000 /path/to/file

adds 12 hours to the modification date

See also touch(1) OS X Manual Page

Thanks Stefan, that looks like it will work perfectly for me.

Here is the much simpler version.

set theFile to (choose file)
tell application "Finder"
	set oldmodDate to the modification date of theFile as date
	display dialog "the old timestamp is: " & oldmodDate
end tell
do shell script "touch -A 120000 " & quoted form of POSIX path of theFile
tell application "Finder"
	set newmodDate to the modification date of theFile as date
	display dialog "the modification time was changed from: " & return & return & oldmodDate & return & return & "to" & return & return & newmodDate
end tell