>>>Possible repost. Sent previously from the wrong email account<<<

So, as discussed earlier I've had a problem with iPhoto not writing the keywords to the actual photo, only to the iPhoto database.

I've found an apple script online that will take the data (like keywords) of selected photos entered into iPhoto and write it to the image file so that it is available for use in other programs, or if the iPhoto database gets corrupted.

the first step is to install the ExifTool command line:
<http://www.sno.phy.queensu.ca/~phil/exiftool/>

Select a photo (or photos) in iPhoto

then run the following Set Exif Data script in Script Editor:
<http://highearthorbit.com/projects/applescript/iPhotoExif.zip>

The problem that I run into is that it seems to give me an error if the keyword has a space in it. For example, running the script on a photo tagged "John Smith" results in an error that says : Error - file Smith not found.

Running the script on the same photo tagged "John_Smith" (with an underscore instead of a space) results in the keyword being written to the files exif/itcp data.

I'm illiterate about applescript. Can someone smarter than me look at the script and see if it could be modified to accept keywords with spaces in them?

Thanks,
Rick
(now i just need to find one to write the GPS locations to the metadata...)


The script is as follows:

-- This applescript will set the exif keywords, name, and comments of all selected iPhoto
--   images using the information current in iPhoto.
--
-- Author: Andrew Turner (http://highearthorbit.com)
--
property copyright : "Copyright Andrew Turner, 2005. All Rights Reserved."
property URL : "http://highearthorbit.com";
property exifToolOriginal : "_original"

-- True retains copyright, False means Public Domain
property Copyrighted : "True"


tell application "iPhoto"
        activate
        try
                copy (my selected_images()) to these_images
                if these_images is false or (the count of these_images) is 0 
then ¬
                        error "Please select a single image."
                
                repeat with i from 1 to the count of these_images
                        set the keywordslist to ""
                        set this_photo to item i of these_images
                        tell this_photo
                                set the image_file to the image path
                                set the image_title to the title
                                set the image_filename to the image filename
                                set the image_comment to the comment
                                set the assigned_keywords to the name of 
keywords
                        end tell
                        repeat with j from 1 to the count of assigned_keywords
set the keywordslist to keywordslist & " -keywords+=" & item j of assigned_keywords
                        end repeat
                        set output to do shell script ¬
                                "exiftool -title='" & image_title & ¬
                                "' " & keywordslist & ¬
                                " " & " -comment='" & image_comment & ¬
                                "' " & " -Copyright='" & copyright & ¬
                                "' " & " -CopyrightNotice='" & copyright & ¬
                                "' " & " -Rights='" & copyright & ¬
                                "' " & " -Marked='" & Copyrighted & ¬
                                "' " & "'" & image_file & "'"
                        do shell script "rm '" & image_file & "'" & 
exifToolOriginal
                end repeat
                
                display dialog "Exif writing complete."
        on error error_message number error_number
                if the error_number is not -128 then
                        display dialog error_message buttons {"Cancel"} default 
button 1
                end if
        end try
end tell


on selected_images()
        tell application "iPhoto"
                try
                        -- get selection
                        set these_items to the selection
                        -- check for single album selected
                        if the class of item 1 of these_items is album then 
error
                        -- return the list of selected photos
                        return these_items
                on error
                        return false
                end try
        end tell
end selected_images 
_______________________________________________
The next Louisville Computer Society meeting will
be February 24 at MacAuthority, 128 Breckinridge Lane. 
Posting address: [email protected]
Information: http://www.math.louisville.edu/mailman/listinfo/macgroup

Reply via email to