• 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: iPhoto events
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: iPhoto events


  • Subject: Re: iPhoto events
  • From: "R. Nelson Byrne" <email@hidden>
  • Date: Sun, 21 Aug 2011 22:16:58 -0700



Thanks a lot, Axel. That info should let me do it. sqlite, huh? OK.

I had imagined the "events" album in the AppleScript model would have contained that data, but it doesn't.

Cheers,


Nelson

On Aug 21, 2011, at 12:00 PM, email@hidden wrote:

From: Axel Luttgens <email@hidden>
Date: August 21, 2011 9:07:18 AM PDT
To: asu <email@hidden>
Subject: Re: iPhoto events
Reply-To: asu <email@hidden>


Le 21 août 2011 à 02:36, R. Nelson Byrne a écrit :

I have two iPhoto libraries I'm trying to reconcile. Each has over 9,000 photos, and over 300 events. There is a great deal of similarity.

I think I can use AppleScript to get a list of the names of all the photos for each album and then sort and compare the two, but I cannot figure out how to tell which photos are in which events.

Any help my with this merge problem will be appreciated.

Hello Nelson,

This one was an interesting one…
I mean, this has been the opportunity to notice how many guesses and workarounds are needed to achieve a seemingly simple task. :-(

Please find hereafter what I managed to devise on Lion and iPhoto 9.1.5 (615).
Not sure if this is exactly what you need; a starting point at least?
Also, note that error checking is inexistent.


on iPhoto_photo2eventname(photoRef)

local libraryPath, originalPath, imagePath

set libraryPath to do shell script "/usr/libexec/PlistBuddy -c 'Print LibraryPath' ~/Library/Preferences/com.apple.iPhoto.plist;"
tell application "System Events" to set libraryPath to POSIX path of (file package libraryPath)

tell application "iPhoto" to set originalPath to original path of photoRef
set imagePath to text (1 + (length of (libraryPath & "/Masters/"))) thru -1 of originalPath

do shell script " /usr/bin/sqlite3 " & quoted form of (libraryPath & "/Database/apdb/Library.apdb") & " \"
SELECT RKFolder.name
FROM RKMaster, RKFolder
WHERE RKMaster.imagePath = " & quoted form of imagePath & "
AND RKMaster.projectUuid = RKFolder.uuid
AND RKFolder.folderType = 2;
\"
"

end iPhoto_photo2eventname


on iPhoto_eventname2photos(eventName)

local libraryPath, originalPaths, photoRefs, originalPath

set libraryPath to do shell script "/usr/libexec/PlistBuddy -c 'Print LibraryPath' ~/Library/Preferences/com.apple.iPhoto.plist;"
tell application "System Events" to set libraryPath to POSIX path of (file package libraryPath)

set originalPaths to paragraphs of (do shell script " /usr/bin/sqlite3 " & quoted form of (libraryPath & "/Database/apdb/Library.apdb") & " \"
SELECT " & quoted form of (libraryPath & "/Masters/") & " || RKMaster.imagePath
FROM RKMaster, RKFolder
WHERE RKFolder.name = " & quoted form of eventName & "
AND RKFolder.folderType = 2
AND RKMaster.isInTrash = 0
AND RKMaster.projectUuid = RKFolder.uuid;
\"
")

tell application "iPhoto"
set photoRefs to {}
repeat with originalPath in originalPaths
set photoRefs to photoRefs & (photos whose original path is originalPath)
end repeat
return photoRefs
end tell

end iPhoto_eventname2photos


Sample usage:


-- Get a reference to some selected photo
tell application "iPhoto" to set P to some item of (get selection)
-- Get the name of the corresponding event
set E to iPhoto_photo2eventname(P)
-- Get photos within that event
iPhoto_eventname2photos(E)


HTH,
Axel






 _______________________________________________
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

  • Prev by Date: Re: Dock Preferences in Lion
  • Next by Date: Re: Dock Preferences in Lion
  • Previous by thread: Re: iPhoto events
  • Next by thread: Entourage 2008 IMAP connection
  • Index(es):
    • Date
    • Thread