0

One of my desktop apps I need to know where the iPhoto Library is installed, programmatically. I do not want to pick it from predicted location (/Users/me/Pictures/iPhoto) since power user may have installed it somewhere else.

I'm developing app using Python and I guess Applescript might have way to figure out iPhoto location but I don't know how.

adamh
  • 3,222
  • 1
  • 20
  • 16
Nilay Anand
  • 330
  • 4
  • 17

4 Answers4

2

One method is to use 'defaults'.

Applescript:

set lib_path to do shell script "defaults read com.apple.iphoto LibraryPath"

Should be similar way to do it straight from Python.

A downside to this is if Apple changes the format of iPhotos preference file in the future and it breaks.

adamh
  • 3,222
  • 1
  • 20
  • 16
  • Works for iPhoto, but not necessarily with other apps. Try iTunes, for example. – Digital Trauma Sep 24 '13 at 15:43
  • Better (and correct) way to use 'defaults' is : set iPhotoLibraryFilePath to (do shell script "defaults read com.apple.iphoto LibraryPath") (no grep needed) –  Sep 24 '13 at 17:11
  • Thanks @DigiMonk have simplified answer based on this – adamh Sep 24 '13 at 20:13
  • @Nilay Anand, wondering why have you un-accepted this answer 4 months later? Has it stopped working for you and the new accepted answer suddenly started working? – adamh Feb 05 '14 at 22:24
1

Why not simply...

set myPath to path to application "iPhoto"
adayzdone
  • 11,120
  • 2
  • 20
  • 37
  • Often the simplest answers are the best - not sure why this is not the accepted one. Also if the path is required with `/` separators instead od `:`, then use this `set myPath to POSIX path of (path to application "iPhoto")` – Digital Trauma Sep 24 '13 at 15:41
  • The poster asks for the location of the iPhoto Library –  Sep 24 '13 at 17:09
  • DigiMonk, Where do you see that? "need to know where the iPhoto is installed" – adayzdone Sep 24 '13 at 17:38
  • He's writing: " I do not want to pick it from predicted location (/Users/me/Pictures/iPhoto)". So I assumed "the iPhoto" means the library :) –  Sep 24 '13 at 18:15
  • DigiMonk is correct. I need to fetch all photos stored inside iPhoto (/Users/me/Pictures/iPhoto Library.photolibrary). – Nilay Anand Sep 25 '13 at 05:38
0

Simply invoke the system command which iPhoto (assuming that you can run iPhoto from a shell) and parse the output.

Steve Barnes
  • 27,618
  • 6
  • 63
  • 73
0

[Removed LaunchServices-based answer as OP apparently wants the location of the iPhoto Library, not iPhoto itself.]

OP should look into Karelia's iMedia framework (dev forum), which includes iPhoto support. The Karelia crew have also done a lot of legwork in figuring out how to make it sandbox/AppStore-compatible, which may also be a consideration depending on how the OP plans to distribute the app.

foo
  • 3,171
  • 17
  • 18