You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Applescript & Photos app: How can I "view" an album?

I've googled a lot but I couldn't find an answer to the following question (also Apple's documentation on Applescript is very poor and is getting worse and worse...):


How can I "view" an album in the Photos main window? "View" here refers to the behaviour when a user clicks on the album name in the sidebar to the left of the main window and hence all media items contained in this album are displayed in the main window.


I couldn't find the Applescript method that would cause this action.


Tried this:

tell application "Photos"
	set a_id to album "IMG_0144.JPG" of folder "Duplicates"
	select album a_id
end tell



but:

error "Photos got an error: album (album id \"336FE692-66EC-46E6-8E65-C28026610BA6/L0/040\" of folder id \"640B17CF-856D-4346-8CB1-892657261A38/L0/020\") doesn’t understand the “select” message." number -1708 from album (album id "336FE692-66EC-46E6-8E65-C28026610BA6/L0/040" of folder id "640B17CF-856D-4346-8CB1-892657261A38/L0/020")


Anyone having an idea how to do this?

MacBook Pro 13”, macOS 10.15

Posted on Jun 26, 2020 10:30 AM

Reply
Question marked as Top-ranking reply

Posted on Jun 27, 2020 12:10 PM

An album will respond to the "spotlight" command . spotlight will select and open it in Photos 5.

I have tested it only with top level albums, not with nested albums in folders.


For example, to open the top level album named "ToRecover" try this:


tell application "Photos"
	activate
	set theAlbumName to "ToRecover" -- some album name
	set myAlbum to container theAlbumName
	tell myAlbum
		spotlight
	end tell
end tell


Similar questions

7 replies
Question marked as Top-ranking reply

Jun 27, 2020 12:10 PM in response to apstef76

An album will respond to the "spotlight" command . spotlight will select and open it in Photos 5.

I have tested it only with top level albums, not with nested albums in folders.


For example, to open the top level album named "ToRecover" try this:


tell application "Photos"
	activate
	set theAlbumName to "ToRecover" -- some album name
	set myAlbum to container theAlbumName
	tell myAlbum
		spotlight
	end tell
end tell


Jun 28, 2020 1:52 AM in response to Old Toad

Old Toad wrote:

Why do you want to use an Applescript for something you can do with one click on the Album icon in the libraries sidebar?


https://discussions.apple.com/content/attachment/9287e547-d75e-4d35-ac18-86746a6d48ba

I am seeing many potential uses for being able to open an album programmatically, if we are having many albums. I am having nearly two thousand albums in my iCloud library in nested folders. So it takes a lot of scrolling and clicking nested folders to open a specific album.


For example, a script, that finds the album a photo is in, could open the album right away, instead of displaying the name of the album and having us looking for it in the sidebar on our own. Or, if our script is creating a new album, where it is collecting photos according to some criteria, we could have the script opening the album with the search results.

Jun 26, 2020 3:41 PM in response to Old Toad

Sounds you don't have a solution for my problem...


Yes, one click if it's one album, but I have, let's say, 100 album and I don't want to click 100 times.


I have created a bunch of albums (also using Applescript) each of which contains a number of potential duplicates (of media items). I want to view each of these albums and then create a dialog in which one can confirm that these images are duplicates or not. Which triggers a corresponding action.

Jun 27, 2020 10:13 AM in response to apstef76

Are you concerned about having a photo in more than one album or having duplicate image files imported into your library. If the former then there's not much we can do.


If the later then you want an app that will identify the potential duplicates, put them in an album or mark them with a keyword for easy retrieval and deletion by you. You don't want one that does the deletion itself for obvious reasons. 


I've run tests on the following apps with these results:


PhotoSweeper - $9.99 - Demo version available. 


PowerPhotos - $29.95  


PowerPhotos is the iPhoto Library Manager version for Photos and is very powerful. Although more expensive I would recommend it as it has more capabilities than the others like the capability to merge Photos libraries or copy photos, both original and edited versions, along with their metadata between libraries.


PhotoSweeper compares bitmaps and/or histograms so it can detect duplicate images even if they have different file sizes, file names, image sizes and capture dates.



Applescript & Photos app: How can I "view" an album?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.