Aperture Applescript

Discussion in 'Mac Programming' started by Sunsplitter, Jun 8, 2012.

  1. Sunsplitter macrumors newbie

    Jun 8, 2012
    I'm new to coding and to Applescript but I managed to cobble together a script for Aperture to copy all the Custom Metadata fields for selected images into Keywords for those images. It works but it runs kind of slowly, and I'm guessing it's because I messed up the repeat function somehow and it's performing the same action multiple times. Could someone with better coding knowledge than I take a look and let me know if there's a fix for this?

    on run
    	tell application "Aperture"
    		set theSel to the selection
    		repeat with i from 1 to number of items in theSel
    			set tImg to item i of theSel
    			repeat with tImg in theSel
    				set theOut to ""
    				repeat with curTag in custom tags of tImg
    					set tagVal to value of curTag
    					set theOut to theOut & tagVal & "," & return
    					set tKey to theOut
    						tell tImg
    							make IPTC tag with properties {name:"Keywords", value:tKey}
    						end tell
    					end try
    				end repeat
    			end repeat
    		end repeat
    	end tell
    end run
  2. kryten2 macrumors 6502a

    Mar 17, 2012
    The first repeat loop goes through every item in your selection. The second repeat loop does the same thing. Remove or comment out the second repeat loop and see if the script does what it needs to do. Repeat loops are notorious for slowing down scripts.
  3. Sunsplitter thread starter macrumors newbie

    Jun 8, 2012
    Ah yeah, that seems to be it. It's going a lot quicker now; thanks for your help.

Share This Page