dbrewood. The first AppleScript can only return one photo. The Find Photos action can find and return multiple photos.
Using one of multiple photos returned by the Find Photos action would not be a good solution, because the photo may have a keyword Processed.
I think the best approach might be to add additional criteria (e.g. image width) to the Find Photos action. The actual criteria would be gotten from the AppleScript and used in the Find Photos action. The criteria used would be based on your analysis of multiple photos returned by the Find Photos action. However, this probably would not work if the duplicates are exact duplicates of one another.
dbrewood. Just to make sure, I downloaded and retested my latest shortcut without issue. However, I only have perhaps 30 photos in the Photos App.
To troubleshoot this issue, I suggest you add a View Content Graph action in the shortcut after the Find Photos action. This will show the actual photos returned. In the following, the Find Photos action only returned one photo.
A possible solution to the above situation is to change the second AppleScript as shown below. The file name with extension would be gotten from the first AppleScript. This is a bit of a kludge, because there might be an entirely different photo with the file name “County Courthouse.heic” and that could be the photo that the shortcut would post to Mastodon.
tell application "Photos"
set keywords of every media item whose filename is "County Courthouse.jpg" to "Processed"
end tell
Another alternative is to change the second AppleScript to that shown below, and this would change both duplicates of “County Courthouse.jpg” to Processed. It would also change “County Courthouse Winter.jpg” and “County Courthouse.heic” to processed. Given the ultimate purpose of the shortcut, this might be a good approach.
tell application "Photos"
set keywords of every media item whose filename begins with "County Courthouse" to "Processed"
end tell
I still think though that is multiples are detected, pick one and work with that, allow that to be processed which will reduce the multiples by one, and if the same photo is selected at another time, process it similarly so the number of multiples are reduces each time that ,name’ is processed?
Or does the duplication ‘situation’ prevent an actual match being made?
If it is the latter then I agree all of those should be marked ‘processed - duplicate’ and when I start to run out oof photos to process I can look to handle those manually.
I’ve 2083 favourites out of 6624 photos in my library so a way to go I guess
I still think though that is multiples are detected, pick one and work with that, allow that to be processed which will reduce the multiples by one,… If it is the latter then I agree all of those should be marked ‘processed - duplicate’ and when I start to run out oof photos to process I can look to handle those manually.
For the most part, that is how the following shortcut works. However, all photos that begin with the file name are marked as “Processed” instead of “Processed - Duplicate” I’ve only spent a limited time with this shortcut, but it did work in limited testing.
I still think though that is multiples are detected, pick one and work with that, allow that to be processed which will reduce the multiples by one, and if the same photo is selected at another time, process it similarly so the number of multiples are reduces each time that ,name’ is processed?
@peavine Thanks for that. I’ve just run the latest shortcut above. I assume my routines should start after your ‘selector’ using the ‘Get First Item from * Photos’ as the source?
Which seems to show that it is not only favourites which are being scanned? I’ve checked the images and processed has been assigned to both photos, the favourite and non-favourite?
In my revised shortcut, I would probably put your routines after the Find Photos action. The Get First Item action wasn’t really necessary, so I deleted it. Your routines could also be put at the very end of the shortcut. This depends on when you actually want to set the keywords of the photos to “Processed”.
@peavine Thanks for that, it is greatly, appreciated. Just completed some texting and on duplicated being found the ‘processed’ keyword was indeed applied to the favourites only.
Hopefully that totally awesome bit of coding will work very well. I’ll look to incorporate it into my Shortcut as soon as I can. It’s our Wedding Anniversary today so coding time will be limited.
I’ll come back to you if I have any issues, but I think I’ll be okay. Once again (as always) my greatest thanks.
dbrewood. Congratulations on your wedding anniversary. I trust you’re having a great day.
It’s good news that we’ve found a solution that is workable and that will allow you to move on with the rest of your shortcut. Our solution is far from perfect, but I suspect it will do the job until Apple adds the ability to get and set keywords in a shortcut.
I had some free time today and looked into whether a date could be used as an additional filter in the Run AppleScript and Find Photos actions. I’m uncertain if the date returned by the AppleScripts and the Find Photos action are of the same property, although the shortcut seemed to work as expected in limited testing. It would almost certainly be significantly slower, though.