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.

Complex Photo Search?

I have my photos and videos well organized, but I have a lot of them (65000 over 18 years). I'd like to search for just my Christmas Videos over that time. There is no way to search for specific month or date but ignore the year. This would apply to birthdays, anniversaries, Burning Man, holidays, etc as well. Other than going back and tagging all of my images, this would seem like something that Siri or any simple search could do since it is just simple metadata. However, I get no results. I am not sure if this is a feature request or just a help issue. It seems like a simple and common problem that is easy to add in.

MacBook Pro with Retina display, macOS High Sierra (10.13)

Posted on Nov 19, 2018 2:21 PM

Reply
14 replies

Nov 20, 2018 12:22 PM in response to léonie

The Apple Script below will collect all photos taken on the fourth of July in an album - for any year.

To search for a different date change the second line "set the month ..." to the month you want and the third line "set the day ..." to the day you want.


To use this script, paste it into a Script Editor window and save it as a new script. Click the Run button. The search will take a long time for a large library.

The result will appear as a new album named for the day and month.

To make the script easier to use, you may add a dialog to ask for the day and month.


------------- copy from here ---------------

-- Find all photos taken on a certain day, for example the day of the current date.

-- The resulting photos will be added to a toplevel album named "On <day> <month>".

-- Author Léonie, March 8,2016



set thisdate to the (current date) as date-- create a date object

set the month of thisdate to 7 -- change this to the month you want, for example 12

set the day of thisdate to 4 -- change this to the day you want, for example "25"


set thisday to the day of (thisdate as date)

set thismonth to the month of (thisdate as date)

--return {thisday, thismonth}


set thisDayAlbum to "On " & thismonth & " " & thisday as string


tell application "Photos"

try


if existscontainerthisDayAlbum then


delete the containerthisDayAlbum


delay 2 -- second try after delay

end if


makealbumnamedthisDayAlbum-- create a new, empty album

on error errTexttwonumbererrNumtwo

display dialog "Cannot create album: " & thisDayAlbum & " " & errNumtwo & return & errTexttwo

return

end try


set onthisdayFound to {}

set onthisdaySkipped to {}



set allTheItems to every media item-- get a list of all photos and videos, may take a while


-- add all photos taken this day to the album


repeat with i from 1 to the count of allTheItems


-- check the dates of all photos and videos

set thisMediaItem to itemi of allTheItems

try

set date_i to the date of thisMediaItem

set day_i to the day of (date_i as date)

set month_i to the month of (date_i as date)

if ((day_i = thisday) and (month_i = thismonth)) then

set end of onthisdayFound to thisMediaItem


add {thisMediaItem} tocontainerthisDayAlbum

end if

on error errTexttwonumbererrNumtwo

set end of onthisdaySkipped to thisMediaItem

end try

end repeat

end tell


set theresultmessage to "Found " & (the count of onthisdayFound) & " items and added them to the album " & thisDayAlbum & ".

Skipped " & (the count of onthisdaySkipped) & " items without date"


display dialogtheresultmessage

Nov 20, 2018 11:09 AM in response to Old Toad

It would be possible by adding a dialog to ask for the day and the month.

Or we could add a dialog with a few buttons for predefined days, for example a button "Christmas", "Thanksgiving", "Dad's Birthday". These would have to be defined by each user personally.


You could try this: The script asks for the day and month in the format dd:mm

After entering the day and month click the OK button, and then wait. It takes several minutes to search my library with 50000 photos.


-- Find all photos taken on a certain day, for example the day of the current date.

-- The resulting photos will be added to a toplevel album named "On <day> <month>".

-- Author Léonie, March 8,2016, modified on november 20, 2018


set userCanceled to false

try

set dialogResult to display dialog ¬

"Enter the day and month in the format dd:mm" buttons {"Cancel", "OK"} ¬


default button "OK" cancel button ¬

"Cancel" giving up after 15 ¬


default answer "24:12"

on error number -128

set userCanceled to true

end try


if userCanceled then


-- statements to execute when user cancels

display dialog "User cancelled."

return "User cancelled."

else if gave up of dialogResult then

display dialog "User timed out."

return "timeout"

end if


-- parse the dd:mm string

set theresult to the text returned of dialogResult


set thisdate to the (current date) as date-- create a date object

set the month of thisdate to ((word 2 of theresult) as number)

set the day of thisdate to ((word 1 of theresult) as number)


set thisday to the day of (thisdate as date)

set thismonth to the month of (thisdate as date)

--return {thisday, thismonth}



set thisDayAlbum to "On " & thismonth & " " & thisday as string


tell application "Photos"

try


if existscontainerthisDayAlbum then


delete the containerthisDayAlbum


delay 2 -- second try after delay

end if


makealbumnamedthisDayAlbum-- create a new, empty album

on error errTexttwonumbererrNumtwo

display dialog "Cannot create album: " & thisDayAlbum & " " & errNumtwo & return & errTexttwo

return

end try


set onthisdayFound to {}

set onthisdaySkipped to {}



set allTheItems to every media item-- get a list of all photos and videos, may take a while


-- add all photos taken this day to the album


repeat with i from 1 to the count of allTheItems


-- check the dates of all photos and videos

set thisMediaItem to itemi of allTheItems

try

set date_i to the date of thisMediaItem

set day_i to the day of (date_i as date)

set month_i to the month of (date_i as date)

if ((day_i = thisday) and (month_i = thismonth)) then

set end of onthisdayFound to thisMediaItem


add {thisMediaItem} tocontainerthisDayAlbum

end if

on error errTexttwonumbererrNumtwo

set end of onthisdaySkipped to thisMediaItem

end try

end repeat

end tell


set theresultmessage to "Found " & (the count of onthisdayFound) & " items and added them to the album " & thisDayAlbum & ".

Skipped " & (the count of onthisdaySkipped) & " items without date"


display dialogtheresultmessage

Nov 20, 2018 12:25 PM in response to Dare2GoFast

These are great answers! And I will try them out. It seems like exactly what Siri should be able to do, but can't. Google photos allows me to search for Christmas videos just fine with a simple search. Seems like Apple has some easy catch up to do and especially if they want to be able to do this sort of work on a local machine for privacy purposes.


Good solutions, and I keep forgetting about AppleScript. My parents will never figure it out, but I can use it at least.

Complex Photo Search?

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