Hi!
I want to create a list with iPhoto album names. No problem doing this the standard way:
tell application "iPhoto"
get name of every album
end tell
But I don´t want iPhoto to launch.
In Automator there is “Ask for Photos” which gives you a perfect list, without launching iPhoto, so there must be a way to do this. But how?
This seems to get it on my system (with iPhoto 5). I’m sure it could do with some tidying up.
getiPhotoAlbums()
on getiPhotoAlbums()
-- Get path to iPhoto's prefernces
set myPrefFile to ((path to preferences folder from user domain) as text) & "com.apple.iPhoto.plist"
tell application "System Events"
--Find iPhoto's root directory from it's preferences
set myPrefPath to the value of property list item "RootDirectory" of property list file myPrefFile
set myXMLFile to myPrefPath & "/AlbumData.xml"
-- Pull album data as records
set myTestPref to the value of property list item "List of Albums" of property list file myXMLFile
end tell
-- Parse Album records for |AlbumName| , adding "Library" and "Trash" automatically
set myAlbums to {}
repeat with myAlbum in items of myTestPref
if |AlbumName| of myAlbum is not "Library" then
if |Album Type| of myAlbum is "regular" then
set end of myAlbums to |AlbumName| of myAlbum
end if
else
set end of myAlbums to "Library"
end if
end repeat
set end of myAlbums to "Trash"
--return array
return myAlbums
end getiPhotoAlbums