Unofficial archive. This is a read-only, community-run archive of the Apple Support Community. It is not affiliated with or endorsed by Apple Inc.

How can I identify which albums photos are assigned to in Photos.

When I view a photo in the Photos stack or in any album, I would like to be able to identify the albums it has been assigned. Does anyone know how to do that? Please understand that I know how to use a smart album to find Unassigned photos, but how to you find albums assigned to photos?


And explanation as to why: It's a very important tool for me to remain consistent in 'filing' photos away and being able to verify they have been filed properly. And it might be a surprise to Apple, but I do not think in terms of date/time/gps when using my photos program. Those are meaningless delineations to me, although they can be useful flags for secondary info in the metadata. Many photos over the years were and still are received via mail or scanned and do not have an appropriate date or gps location attached. Faces is useful, but viewing 5k pictures of 'mom' without knowing which album they are in, is not helpful.

29 replies

Hello,


socraties wrote:


Would it work to program an Apple Script, then insert it in the contextual menu so that I can select any picture and run the script? If so it would be a great workaround!!! Do you think there may be an automator or Apple script out there that already exists? I'm hopeful.


This AppleScript show the name of albums which contains the selected photo:


tell application "Photos"
    set sel to selection
    if sel is {} then return -- no selection
    set thisId to id of item 1 of sel
    set theseNames to name of (albums whose id of media items contains thisId)
end tell
if theseNames is not {} then
    set {oTid, text item delimiters} to {text item delimiters, return}
    set {t, text item delimiters} to {theseNames as string, oTid}
else
    set t to "No album"
end if
activate
display dialog t buttons {"OK"} default button "OK" -- you can press the Enter key or the return Key to close the dialog



You can run this AppleScript from an Automator's service, and you can assign a shortcut to this service.


Or, you can run this AppleScript from some third party utilities (some free) which run (shell script, AppleScript script or javascript), and you can assign a shortcut to this action

Please understand that I know how to use a smart album to find Unassigned photos, but how to you find albums assigned to photos?

Photos does not support this. You cannot get a list of standard albums a photo has been assigned to.


If you want to know for a photo, which albums a photo is in, use only smart albums based on keywords. You can see the keywords in the Info panel for a photo and know directly, which smart albums will contain it.


To find all standard albums a photo is in you would have to program an Apple Script.

It is a very valuable starting point. When I tried to write a similar script, I always failed when comparing the ids of the photos, Your line "whose id of media items contains thisId" was the missing link for me! 😎


Apple scripts do not work well with iCloud Photo Library at all, if they are trying to access the current selection. It will result in time out errors.

There is a fix by NicFletcher - create a top level album that contains the photos to be processed. Here is Nic's sample script, that uses this method:

https://discussions.apple.com/thread/6999613?answerId=28087786022#28087786022


I am using a fixed album called PhotosDropBox to pass photos to scripts.

For iCloud Photo Library I might modify your script like this:


tell application "Photos"


-- Add the photo you want to search for to a top level album as the first item in the album

set theAlbumName to "PhotoDropBox" -- change this to the name of the album you will use

try


if existscontainertheAlbumName then


set thePhotosBuffer to containertheAlbumName

set sel to every media item of thePhotosBuffer

else

error "Album " & theAlbumName & "does not exist"

end if


on error errTexttwonumbererrNumtwo

display dialog "Cannot open album: " & errNumtwo & return & errTexttwo

end try

end tell


-- From Jacques Rioux's script:

tell application "Photos"


-- set sel to selection

if sel is {} then return -- no selection

set thisId to id of item 1 of sel

set theseNames to name of (albums whose id of media items contains thisId)

end tell


if theseNames is not {} then

set {oTid, text item delimiters} to {text item delimiters, return}

set {t, text item delimiters} to {theseNames as string, oTid}

else

set t to "No album"

end if

activate

set the clipboard tot-- léonie

display dialogtbuttons {"OK"} default button "OK" -- you can press the Enter key or the return Key to close the dialog

return t-- léonie

I have found a useful workaround for any timeout errors (error message -1712) that occur with any or Jacques Rioux's excellent scripts - for example this solved the timeout issues I was getting for the import folders as albums scripts. You just need to give the Mac a bit more time to count images etc: the default is 60 seconds, which often isn't enough. So rather than workarounds involving creating a parent folder, all you need to do is edit the script and add a timeout instruction and a close instruction after every event. So for this script I modified it thus:

tell application "Photos"

set sel to selection

with timeout of 10000 seconds

if sel is {} then return -- no selection

set thisId to id of item 1 of sel

set theseNames to name of (albums whose id of media items contains thisId)

end timeout

end tell

if theseNames is not {} then

set {oTid, text item delimiters} to {text item delimiters, return}

set {t, text item delimiters} to {theseNames as string, oTid}

else

set t to "No album"

end if

activate

display dialogtbuttons {"OK"} default button "OK" -- you can press the Enter key or the return Key to close the dialog

And it's a take-away because it was available in iPhotos and Aperture.

In you could reveal the project a photo is in, and in iPhoto you could reveal the event. Neither of them could revel the albums. The difference is, that any photo was in only one event in Photos or in only one project in Aperture. But it can be in many albums, and neither iPhoto nor Aperture could reveal photos in albums. t is exactly the same in Photos.


The iPhoto events and Aperture projects have been replaced by the moments, and you can reveal a photo in the moment by ctrl-clicking it and selecting "Show in Moment".

Do you think there may be an automator or Apple script out there that already exists? I'm hopeful

I have not yet found such a script.

I appreciate your response. I was afraid that would be true. It helps me understand the Photos perspective better though. Too bad that this inability to identify albums is a fatal limitation for me. And it's a take-away because it was available in iPhotos and Aperture.


One, I already have 25000 photos set up in albums. Two, I use pictures to locate other pictures. For example: If I see a picture of something (e.g. Fluffy the cat in a row boat), then I can recall other things that happened at that time. Perhaps that is the same day (album or event) that my friend emailed me the picture he took of me falling out of the boat. You see, if the pictures do not have the appropriate date/time, the only way they are linked is by the album I filed them into. And if Photos will not let me access that link, then how will I be able to interface with the groupings Apple assigns instead of the groupings I assign? Pictures are not individual items that exist in a vacuum. I do appreciate your feedback though.


Unfortunately, if I move to a third party photo system to regain that functionality, then iCloud loses its shine unless there is a third party application that will let me manage my photos AND integrate with iCloud via my iPhone, iPad, iPod, and my iMac. If I want to cobble third party apps into a generic cloud solution, then Android sounds less kludgy.

Would it work to program an Apple Script, then insert it in the contextual menu so that I can select any picture and run the script? If so it would be a great workaround!!! Do you think there may be an automator or Apple script out there that already exists? I'm hopeful.

Thank you again. I see what you are saying! I used Events and Projects in iPhoto and Aperture because the temporary nature of the Album link made me uncomfortable. Aperture Projects were 'converted' to Albums in Photos. I would love to find an Apple Script that does this kind of thing. Or even learn to write one and insert it into contextual menus. Perhaps I'm looking for Apple to provide more of a database functionality and search tool to their Photos program. I sure didn't have these issues in Aperture.


You have been tremendously helpful. Thank you again.


One more question regarding Smart Albums. Can we insert an "or" statement between or after "and" statements.


For example:


Face includes Myron AND

Face includes Louise AND

(Album = Mother's Day OR Album = Father's Day)


Also, I wonder if it's possible to use 'contains' with 'Folder' (neither of which I see in smart album searches). i.e., Folder Contains Holiday


Again, I really appreciate the time you've taken to respond. It's been helpful, I see why you have so many points!

I also see what you mean by Moments. Moments simply does not work though because it uses file dates from the metadata. File dates are frequently incorrect. Almost all of my scanned photos have scanned dates. So the file would be assigned to 1st birthday in Aperture which would be pictures of the 1st birthday. Unfortunately, those pictures of the 1st birthday are spread across Moments because they were scanned, rescanned, emailed, or screen printed. It's not possible to manually change the varying dates on thousands of files. First I'd have to look up the date each photo was taken (from 40 years ago?) then I'd have to insert the varying dates into the metadata for each photo.


So I wish that Projects/Events had not been abandoned.

The moments are using the capture dates, if they are available.


For my scanned photos I added capture dates using an apple script.


We posted a few scripts in the User Tips section: Photos for Mac User Tips


You may want to have a look at this script: Photos for Mac: Batch Change the Date and Time to a Fixed Date


It will basically take a few selected photos and then change the date of the photos to the date of the first photo, but add a small increment between successive photos, for example 1 minute. This way the photos will have the same date and time as the first photo, but if sorted by the date, the sequence will be the same, because of the increment in time.


Moments can be quite powerful, if the photos have been tagged with useful dates and with location data. Then Photos will group photos taken at the same tie at the same place together. But it requires Photos 1,2 or later; otherwise it is not possible to assign locations in Photos.

I'm reviewing your links, and links in the links. Lot's of info. Useful information that helps my learning curve. Another one I'm trying to wrap my head around when it comes to Moments is 'timeless and eventless' photos. For example, I collect old photos of my ancestors (i.e., grandparents, great grandparents, great-great grandparents, and my great aunts and uncles). Right now, they drop into the Moment based on the Scan date. For example, I took a picture of my dad in the hospital on the same day I scanned some pictures of him as a kid. I don't have a real date to assign them to. But my dad riding a tricycle really doesn't belong next to him elderly laying in a hospital bed. They are really 'Dateless' entities. My Great grandmother and Great-Great Grandmother seem to live in the same timeframe from my brain's perspective, but if you could ask them, their lives were completely full and separate with some overlapping events. Can we insert Text instead of a date for Moments? For example, can I call (a) moment "1st Generation ancestors", "2nd Generation ancestors", etc? Can I call a moment "Dad Growing Up"? That way I will not get such a collage of pictures within incorrect date ranges. I'm still struggling trying to believe that the key identity to a picture or the relationship between pictures is a date, or even a geographic location. Those are great attributes to record, but they are not great identities to use as defining the event. Of course the best solution (and easiest) is to use Events/Projects instead of Moments.


Anyway, I'm going to increase my learning curve on Photos and continue to investigate solutions for my problem. Thanks again for hanging in there with me. It has been really really helpful! I know you didn't have to do it, which makes me appreciate it all the more.

I assign estimated dates and locations to my scans of old family pictures and add a keyword, that date and location are estimates.Also I assign faces labels. The dates and locations will help to sort the photos and show them on a map.

Can we insert Text instead of a date for Moments? For example, can I call (a) moment "1st Generation ancestors", "2nd Generation ancestors", etc? Can I call a moment "Dad Growing Up"?

Moments are created automatically and we cannot name them. I use albums to give names to related sets of photos. The folders, albums, and smart albums will replace the iPhoto events or Aperture projects.

User uploaded file

Great work, Jaques!


The script is working well on my small local test library.


May I suggest to add a line;

set the clipboard tot

right before the last "display dialog"?

This way the result will be copied to the clipboard, and we can paste it into any text document and do not need to copy it manually from the dialog panel.

When I try the script on my iCloud Photo Library with nearly 40000 photos however, I get a timeout error:

error "Photos got an error: AppleEvent timed out." number -1712

I'm getting the same error for any script that is using the "selection" to pass photos to a script, if the library is an iCloud Photo Library-

Hello,


léonie wrote:


Jaques,

would you mind, if we post a link to your script in the user Tip section?


-- Léonie


Yes, you can do it.


Thank you.


léonie wrote:



When I try the script on my iCloud Photo Library with nearly 40000 photos however, I get a timeout error:

error "Photos got an error: AppleEvent timed out." number -1712

I'm getting the same error for any script that is using the "selection" to pass photos to a script, if the library is an iCloud Photo Library-


This script was a starting point, I suspected that it would not be free of issues.

Unfortunately, I only have a small library, and I don't use iCloud.

If there are people who can improve this script, I'd be happy.


Jacques.

Thank you both, léonie et Jacques ! I will work on testing the script on my system. I think it will work well in my situation because I have only a little over 25000 photos and they are stored locally. They do upload to the cloud but I retain a copy locally (Download Originals to this Mac in Photos iCloud preferences).


It will take me a little while to test it (I'm not proficient in scripts or automator) but I promise to flag 'solved my problem' when done. Thank you both for working on this, it's incredible.

Hello,


socraties wrote:


Jacques - I'm having trouble setting this up. Maybe it's easy for you to see what I'm doing wrong. Two problems:


1 - I receive this error when clicking on the "Step" button in Automator.

User uploaded file


This is the syntax I copied and manually typed into the Automator Script window:


User uploaded file




It lacks the "s" character in the first button word.

display dialogtbuttons {"OK"} default button "OK"


Or, you can use this line (the dialog show two buttons, a default and a cancel buttons).

display dialogt
-- you can press the Enter key or the return Key to close the dialog

socraties wrote:


Second Problem:


I added it to Services twice. But it doesn't show up in the Services Menu in Photos (or anywhere).



This is because Photos doesn't work with a service of type (Images).

Don't try to change it on your service, it will not change the original type on the already saved service


You must create a new service.

Select "No Input" from the first popup button --> Service receive: "No Input" from application: "Photos"


After the saving, this service will be in the "General" services, not in the "Images" services

Hi Jacques - This is beautiful. Thank you so much for this script. I followed your advice and it works great. Ultimately I used "display dialogt" and dropped the

"buttons {"OK"} default button "OK" ". It runs great and presents a dialog with the list of Albums. To release the dialogue, I simply click OK or the Return Key.

Wow, wow, wow, wow. I could pee in my pants. Thank you SOO much for your time and effort.

russ

I have somewhat the same problem. I just need to select the images that are not in any album so I can complete organizing; very simple request.

The smart album: 'Album - IS NOT - any' works only partially. It sorts out thousands of images properly but leaves out thousands more images not in any album.

High Sierra, 32G M OS 10.13.2


Why does this smart album logic work on some images and not on others?

I don't see anything specific in the info box that's different from an album image to an image not in an album.

Jacques - I'm having trouble setting this up. Maybe it's easy for you to see what I'm doing wrong. Two problems:


1 - I receive this error when clicking on the "Step" button in Automator.

User uploaded file


This is the syntax I copied and manually typed into the Automator Script window:


User uploaded file


Second Problem:


I added it to Services twice. But it doesn't show up in the Services Menu in Photos (or anywhere).


User uploaded fileUser uploaded file


Is it possible to see what 00004000 I'm doing wrong or am I simply too remedial on this subject? Thanks for your help on this. I hope it helps a lot of other people too!


russ

You can with the script that léonie posted just after your post. You can download a compiled version of the script as an application from this tutorial site: P01 - Applescripts from Photos’ User Tips Compiled as Applications


User uploaded file

Jaques,

would you mind, if we post a link to your script in the user Tip section?


-- Léonie

Do you have hidden photos in your library? They will not show in any album, unless you add a rule"Photos hidden".

On macOS 10.12.4 Sierra we do no longer need the work-around with the top level album.


This version of the script is using the current selection, but has a few added error tests:


-- Select the photo in Photos, then run this script by pressing the "Run" button in the script editor or from the scripts menu.


tell application "Photos"


activate


-- Add the photo you want to search for to a top level album as the first item in the album


set resultcaption to "Searching for: "

try


set sel to selection

if sel is {} then error "The selection is empty" -- no selection


on error errTexttwonumbererrNumtwo

display dialog "No photos selected " & errNumtwo & return & errTexttwo

return

end try


set imagename to "unknown filename"

try

set targettoitem 1 of sel-- the image to seach for

tell target

set imagename to the filename of target

end tell

on error errTexttwonumbererrNumtwo

display dialog "Cannot get the filename of the first image: " & errNumtwo & return & errTexttwo

end try

set resultcaption to (resultcaption & imagename)

end tell


try


display alertresultcaptionbuttons {"Cancel", "OK"} asinformationalgiving up after 2

on error errTextnumbererrNum

if (errNum is equal to -128) then


-- User cancelled.

return

end if

end try

-- From Jacques Rioux's script:

tell application "Photos"


-- set sel to selection

if sel is {} then return -- no selection

try

set thisId to id of item 1 of sel

on error errTextnumbererrNum

display dialog "Error: cannot get the image ID" & errNum & return & errText & "Trying again"


try

delay 2

set thisId to id of item 1 of sel

on error errTexttwonumbererrNumtwo

display dialog "Skipping image due to repeated error: " & errNumtwo & return & errTexttwo

error "giving up"

return

end try --second attempt

end try


set theseNames to {}

try

set theseNames to name of (albums whose id of media items contains thisId)

on error errTextnumbererrNum

display dialog "Error: cannot get the albums" & errNum & return & errText & "Trying again"

try

delay 2

set theseNames to name of (albums whose id of media items contains thisId)

on error errTexttwonumbererrNumtwo

display dialog "Skipping image due to repeated error: " & errNumtwo & return & errTexttwo

error "giving up"

return

end try

end try

end tell


if theseNames is not {} then

set {oTid, text item delimiters} to {text item delimiters, return}

set {t, text item delimiters} to {theseNames as string, oTid}


-- return oTid

else

set t to "No album"

end if

activate


set resultcaption to resultcaption & ", found it in these albums:

" & t as string

set the clipboard toresultcaption

display dialogresultcaptionbuttons {"OK"} default button "OK" -- you can press the Enter key or the return Key to close the dialog

returnresultcaption-- léonie

Thanks to léonie and Jacques for making these scripts available. I used the first script posted in the user tips area. It works fine with Photos in El Capitan (albeit a little slow). I run it as a script in an Automator workflow.

So the answer apparently is, "you can't." I was trying to do the same thing.

The answer is the second entry which is marked "SOLVED" - use the suggested Apple Script


LN

You're welcome 🙂