so, is there some way to modify the Set Exif Data script to reflect these changes for all of my keywords (I have hundreds of them), without actually having to enter in something for each name?

some sort of "if there is a space, insert \" command?

Rick


-- 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

On Feb 14, 2009, at 11:26 AM, Lee Larson wrote:

On Feb 14, 2009, at 11:19 AM, Rick Burnett wrote:

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.

When passing parameters to Unix command line tools, spaces are usually used as the break between separate parameters. So

somecommand john smith

actually has two parameters. To turn it into one parameter either escape the space with \ followed by space

somecommand john\ smith

or quote the parameter

somecommand 'john smith'




_______________________________________________
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

_______________________________________________
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