This (hastily hacked together) AppleScript corrects the dates in iPhoto for imported photos that follow my canonical naming convention (YYYYMMDDHHMMSS.jpg
) but which lack EXIF tags for some reason.
tell application "iPhoto"
set photoList to selection
set theMonths to {January, February, March, April, May, June, July, August, September, October, November, December}
repeat with thePhoto in photoList
set thefile to (image filename of thePhoto)
set newDate to current date
set month of newDate to (item ((text 5 thru 6 of thefile) as number) of theMonths)
set day of newDate to (text 7 thru 8 of thefile)
set year of newDate to (text 1 thru 4 of thefile)
try
set time of newDate to ((text 9 thru 10 of thefile) * hours + (text 11 thru 12 of thefile) * minutes + (text 13 thru 14 of thefile))
on error
try
set time of newDate to ((text 9 thru 10 of thefile) * hours + (text 11 thru 12 of thefile) * minutes + 0)
on error
set time of newDate to 0
end try
end try
log newDate
tell application "iPhoto"
select thePhoto
if date of thePhoto is newDate then
else
set date of thePhoto to newDate
end if
end tell
end repeat
end tell