Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Sunsplitter

macrumors newbie
Original poster
Jun 8, 2012
2
0
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?

Code:
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
					try
						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
 
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.
 
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.

Ah yeah, that seems to be it. It's going a lot quicker now; thanks for your help.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.