• 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
Re: Why does this iPhoto applescript fail to produce new albums with photos in them?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why does this iPhoto applescript fail to produce new albums with photos in them?


  • Subject: Re: Why does this iPhoto applescript fail to produce new albums with photos in them?
  • From: "Andrew T. Lynch" <email@hidden>
  • Date: Thu, 10 Mar 2005 14:16:52 -0800

Hello Kai, and thanks for responding. I benchmarked your version of the script against the one I used (included below), and they are about the same performance wise. My problem seems to be that my image library is large, >23,000 images. While iPhoto's performance is fine via the GUI, it goes to heck via applescript. I ran your script and mine with 9 images selected, and they each completed in about 35 seconds. I assume that the performance per image would improve with more images, as the time needed to create the album would be amortized over more images.

BTW, In my book, anybody who can write this:
	"tell startPhoto + albumSize - 1 to if it > photoCount then"
is a guru :-)  Makes my head hurt.

A funny story about "zymurgist": I've had the official title "Chief Zymurgist" for about 8 years (I used to brew the beer for the company parties when we were a startup). We recently hired a new docs manager, and she let me know (gently) that zymurgist is not a word. The correct word for one who studies zymurgy is "zymologist" which just doesn't have the right ring to it.

Here is the script I ended up using. I just went in the hot tub and let it finish.

tell application "iPhoto"
	set albumcount to 0
	set photoCount to 0
	copy (my selected_images()) to thePhotos
	if the thePhotos is false then error "Please select some images."
	set thePhotosRef to a reference to thePhotos
	set theCount to the count of thePhotosRef
	repeat with i from 1 to the theCount
		if photoCount is equal to 0 then
			set albumcount to albumcount + 1
			set albumName to "Test " & albumcount
			new album name albumName
			set theAlbum to album albumName
		end if
		add item i of thePhotosRef to theAlbum
		set photoCount to photoCount + 1
		if photoCount is 48 then
			set photoCount to 0
		end if
	end repeat
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

Thanks Again,
   Drew

On Mar 10, 2005, at 1:20 PM, kai wrote:


On Thursday, March 10, 2005, at 08:47 pm, I wrote:

Frankly, I'm not entirely sure if the following will improve matters for you. If it doesn't, then I doubt you'll speed things up significantly with things as they stand. Still, it might be worth a go...

I just noticed on the web archives that the script I included came out as utter gobbledygook. (Please - spare me the "so what's new?" comments!) ;-)


For the benefit of anyone affected, here's a plain text version. (Some long lines may need to be rejoined):

---------

property albumSize : 48 (* modify as required: maximum 48 *)

to getPhotoList()
tell application "iPhoto" to tell (get selection) to try
if item 1's class is album then error
it
on error
tell current application to display dialog "Please select some images first." buttons {"Cancel"} default button 1 with icon 0
end try
end getPhotoList


set photoList to getPhotoList()
set photoCount to (count photoList)

tell application "iPhoto" to repeat with startPhoto from 1 to photoCount by albumSize
tell startPhoto + albumSize - 1 to if it > photoCount then
set endPhoto to photoCount
else
set endPhoto to it
end if
set albumName to "Page " & startPhoto div albumSize + 1
new album name albumName
tell album albumName to repeat with currPhoto in photoList's items startPhoto thru endPhoto
add currPhoto to it
end repeat
end repeat


---------

---
kai


- Andrew T. Lynch
- Chief Zymurgist
- Verisity Design Inc.
- (650)934-6875

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Re: Why does this iPhoto applescript fail to produce new albums with photos in them? (From: kai <email@hidden>)

  • Prev by Date: Re: date calculations
  • Next by Date: Re: Strange Script editor behaviour
  • Previous by thread: Re: Why does this iPhoto applescript fail to produce new albums with photos in them?
  • Next by thread: Re: Why does this iPhoto applescript fail to produce new albums with photos in them?
  • Index(es):
    • Date
    • Thread