Hi… this is my first post… I am having a problem getting a handle on the original file when “Copy files to iPhoto Library Folder” flag is unchecked in the iPhoto advanced properties. This causes the files to not be copied to the iPhoto Library. A JPG gets copied to the library without the exif information contained in the original. I am using a modified script from http://www.joemaller.com/iphoto/iphoto_scripting.html. I changed it to use exifTool to support CRW files. My problem is that the photo object has no properties that point to the original file. I downloaded a demo of Script Debugger 4 to walk through the code.
Original file /Users/Bordelcl/Pictures/Canon/117CANON/CRW_1772.CRW
from the photo object:
image path “/Users/bordelcl/Pictures/iPhoto Library/Modified/2005/117CANON/CRW_1772.jpg”
thumbnail path “/Users/bordelcl/Pictures/iPhoto Library/Data/2005/117CANON/CRW_1772.jpg”
Here is the code (just the parts I am working with)
The full script was downloaded from here - http://www.joemaller.com/iphoto/iphoto_scripting.html
on getEXIFdate(imgFile)
-- original subroutine by Joe Maller <http://www.joemaller.com>
-- authored March 2005
-- licensed under Creative Commons Attribution Non Commercial ShareAlike 2.0
-- http://creativecommons.org/licenses/by-nc-sa/2.0/
-- v1.5 (May 2005) significant speed increase by combining everything into one PERL script
-- send in a Macintosh file reference for a JPEG file, returns the EXIF date string without timezone information.
copy (do shell script "perl -e 'open(IMG, \"" & POSIX path of imgFile & "\");read(IMG, $exif, 1024);$exif =~ s/\\n/ /g;;$exif =~ s/.*([0-9]{4}(?::[0-9]{2}){2} [0-9]{2}(?::[0-9]{2}){2}).*$/$1/g; print STDOUT $exif;'" without altering line endings) to foundDate
if length of foundDate is 19 then return foundDate -- regex failed, probably no EXIF data
return false -- not JPEG or length is greater than 20
end getEXIFdate
on EXIFtoolDate(imgFile)
--CLEB added to use exiftool to work with CRW files
copy (do shell script "exiftool -S -s -d '%m:%d:%Y' -DateTimeOriginal '" & POSIX path of imgFile & "'" without altering line endings) to foundDate
if length of foundDate is 10 then return foundDate -- regex failed, probably no EXIF data
return false -- not JPEG or length is greater than 20
end EXIFtoolDate
tell application "iPhoto"
activate -- is this still necessary?
set photoList to selection
if class of item 1 of photoList is album then -- if class of item 1 is album, there is probably nothing selected
display dialog "Please select one or more photos/movies before running this script." with icon 1
else
my iPhotoShowInfoPane()
set startTime to current date
repeat with thePhoto in photoList
--set theDate to my iPhotoGetOriginalDate(thePhoto)
--This ( thePhoto ) is the object that does not contain the path to the original photo
set theDate to my EXIFtoolDate(thePhoto)
if |type| of theDate is "photo" then set PhotoCount to PhotoCount + 1
if |type| of theDate is "movie" then set MovieCount to MovieCount + 1
set theDate to date of theDate
if theDate is null then -- no date found
set setDate to 0
set resultSkipped to resultSkipped + 1
else -- date was found
set setDate to my iPhotoSetDate(thePhoto, theDate)
if setDate is 1 then -- date was reset
set resultReset to resultReset + 1
else if setDate is 2 then -- dates matched
set resultUnchanged to resultUnchanged + 1
end if
end if
set elapsedSeconds to ((current date) - startTime)
end repeat
my updateReport(PhotoCount, MovieCount, resultReset, resultUnchanged, resultSkipped, elapsedSeconds)
end if
end tell
thanks in advance…