• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
How do I avoid a Repeat loop to abort upon errors?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How do I avoid a Repeat loop to abort upon errors?


  • Subject: How do I avoid a Repeat loop to abort upon errors?
  • From: André Sartori <email@hidden>
  • Date: Sun, 25 Oct 2009 23:34:47 +0000

I am attempting to use an applescript to embed metadata to each of my
iphoto library's photographs. The problem is that some of the photos
cause an error in the last part of the loop (exiftool, a command line
application, fails to write data to a few photos), which causes the
loop to be aborted. I would like to implement into this repeat loop:
1-) in case of error, the error is exported to a log file
2-) the photo that caused the error is skipped and the repeat loop
continues with the next photo

Below is the repeat loop I am currently using (adapted from the script
I found here http://highearthorbit.com/289/). How could I skip
eventual errors?  Please bear in mind that I have just begun exploring
applescript. Thanks in advance.

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 & ¬
				" " & " -Caption-Abstract=\"" & image_comment & ¬
				"\"" & " -Copyright='" & copyright & ¬
				"' " & " -CopyrightNotice='" & copyright & ¬
				"' " & " -Rights='" & copyright & ¬
				"' " & " -Marked='" & Copyrighted & ¬
				"' " & "\"" & image_file & "\""
			do shell script "rm \"" & image_file & "\"" & exifToolOriginal
		end repeat


--
Andre F Sartori
Department of Earth Sciences
University of Cambridge
Downing Street
Cambridge
CB2 3EQ
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: How do I avoid a Repeat loop to abort upon errors?
      • From: LuKreme <email@hidden>
  • Prev by Date: OT: Re: Passing ampersands through a shell script
  • Next by Date: Re: How do I avoid a Repeat loop to abort upon errors?
  • Previous by thread: Re: Wrong day name in Date format
  • Next by thread: Re: How do I avoid a Repeat loop to abort upon errors?
  • Index(es):
    • Date
    • Thread