Solamanzi

Q: "On This Day" Feature for mac Photos, does it exist?

Hello,

 

I love the Facebook feature "On this Day" but would love to have it on my mac rather than upload my entire photo collection to FB for this to work year on year etc. Does anybody know how to replicate this through scripting, 3rd party app etc?

Posted on Mar 6, 2016 1:44 PM

Close

Q: "On This Day" Feature for mac Photos, does it exist?

  • All replies
  • Helpful answers

Previous Page 2
  • by Solamanzi,Solvedanswer

    Solamanzi Solamanzi Mar 8, 2016 7:21 AM in response to léonie
    Level 1 (0 points)
    Mar 8, 2016 7:21 AM in response to léonie

    Yep! You Sir Léonie are a legend! This works a treat!Screen Shot 2016-03-08 at 15.20.24.png

  • by Solamanzi,

    Solamanzi Solamanzi Mar 8, 2016 7:23 AM in response to léonie
    Level 1 (0 points)
    Mar 8, 2016 7:23 AM in response to léonie

    Crumbs I meant to credit your post and instead credited my own flipping entry... Is there a way I can undo? If not thank you for your help. Léonie

  • by léonie,

    léonie léonie Mar 8, 2016 7:54 AM in response to Solamanzi
    Level 10 (105,806 points)
    iCloud
    Mar 8, 2016 7:54 AM in response to Solamanzi

    I just noticed, the 1st of December is also not found, if I simply set the the day and  the month manually.

    When I change the script to first create a date object, and then change the day and month field in the date object, this date is found as well:

     

    You may want to try this modification:

    -- 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".

     

     

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

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

    set the day of thisdate to 1 -- 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, this month} -- just testing

     

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

     

    tell application "Photos"

      try

     

      if exists container thisDayAlbum then

     

      set thePhotosBuffer to container thisDayAlbum

      else

      make album named thisDayAlbum

     

      end if

      on error errTexttwo number errNumtwo

      display dialog "Cannot open 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 item i 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} to container thisDayAlbum

      end if

      on error errTexttwo number errNumtwo

      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 dialog theresultmessage

  • by Solamanzi,

    Solamanzi Solamanzi Mar 8, 2016 8:51 AM in response to léonie
    Level 1 (0 points)
    Mar 8, 2016 8:51 AM in response to léonie

    Yep thats works a treat.

     

    Thanks.

  • by léonie,

    léonie léonie Mar 8, 2016 8:55 AM in response to Solamanzi
    Level 10 (105,806 points)
    iCloud
    Mar 8, 2016 8:55 AM in response to Solamanzi

    You're welcome  

    Programming with the class "Date" is always a fight, because AppleScript has no date constructor that is working independent of the localization.

  • by Solamanzi,

    Solamanzi Solamanzi Mar 8, 2016 9:11 AM in response to léonie
    Level 1 (0 points)
    Mar 8, 2016 9:11 AM in response to léonie

    One other quick question:

     

    tell application "Photos"

      try

     

      if exists container thisDayAlbum then

      delete (every item of folder (thisDayAlbum))


    How do I get the "On This Day" Album emptied so each day it simply refreshes with the current days data?

  • by Old Toad,

    Old Toad Old Toad Mar 8, 2016 9:15 AM in response to Solamanzi
    Level 10 (140,918 points)
    Photos for Mac
    Mar 8, 2016 9:15 AM in response to Solamanzi
    How do I get the "On This Day" Album emptied so each day it simply refreshes with the current days data?

    You don't have to because the album is created with the date selected:

    Photos001.jpg

    So just change the date, run it, change the date, run it, etc., etc., etc.

  • by Solamanzi,

    Solamanzi Solamanzi Mar 8, 2016 9:23 AM in response to Old Toad
    Level 1 (0 points)
    Mar 8, 2016 9:23 AM in response to Old Toad

    By creating an "On This Day Album" I can set the screensaver to use the contents each day. Thus I would like to remove yesterday's files and insert todays files, instead of creating new albums every day etc

  • by Old Toad,

    Old Toad Old Toad Mar 8, 2016 9:30 AM in response to Solamanzi
    Level 10 (140,918 points)
    Photos for Mac
    Mar 8, 2016 9:30 AM in response to Solamanzi

    Thus I would like to remove yesterday's files and insert todays files, instead of creating new albums every day etc.


    Just delete the previous on this day album. That way the date is indicated on the album for reference.

  • by Solamanzi,

    Solamanzi Solamanzi Mar 8, 2016 10:19 AM in response to Old Toad
    Level 1 (0 points)
    Mar 8, 2016 10:19 AM in response to Old Toad

    I could do that, but I guess part of this process is to remove as many manual steps as possible... Léonie has answered my initial question, I am now just pushing the scope a bit ;-)

  • by Old Toad,

    Old Toad Old Toad Mar 8, 2016 10:21 AM in response to Solamanzi
    Level 10 (140,918 points)
    Photos for Mac
    Mar 8, 2016 10:21 AM in response to Solamanzi
    I could do that, but I guess part of this process is to remove as many manual steps as possible.

    Count the steps to launch Script Editor, edit the script, save, close Script Editor and run against  Control (right) - clicking on the smart album, edit the setting and saving.

  • by léonie,

    léonie léonie Mar 8, 2016 11:12 AM in response to Solamanzi
    Level 10 (105,806 points)
    iCloud
    Mar 8, 2016 11:12 AM in response to Solamanzi

    I would simply ctrl-click the album in Photos sidebar and select "Delete Album" from the pop-up menu before you run the script.  It will delete the album, but keep your photos in the library.

     

    If you want to start with an empty album and include this deletion into the script, do it this way:

    If the album exists, delete it, then recreate it unconditionally. This way the script will always start with an empty album.

      if exists container thisDayAlbum then

         delete the container thisDayAlbum

      end if

      make album named thisDayAlbum


    The script will now look like this:

    ------------------------------------------------------------

     

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

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

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

     

    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 exists container thisDayAlbum then

         delete the container thisDayAlbum

      end if

      make album named thisDayAlbum

      on error errTexttwo number errNumtwo

      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 item i 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} to container thisDayAlbum

      end if

      on error errTexttwo number errNumtwo

      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 dialog theresultmessage

     

     

     

    If you are seeing an alert "Apple event timed out", you may not have responded to the dialog panel.  This can happen, if the panel is hidden behind other windows.

  • by léonie,

    léonie léonie Mar 8, 2016 11:20 AM in response to léonie
    Level 10 (105,806 points)
    iCloud
    Mar 8, 2016 11:20 AM in response to léonie

    Come to thing about it, I would insert a line "delay 2" after the deletion of the album. This will avoid timeout errors, if Photos needs bit longer to delete the album.

     

    try

     

      if exists container thisDayAlbum then

        delete the container thisDayAlbum

        delay 2 -- second try after delay

      end if

      make album named thisDayAlbum -- create a new, empty album

      on error errTexttwo number errNumtwo

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

      return

    end try


  • by Solamanzi,

    Solamanzi Solamanzi Mar 8, 2016 1:20 PM in response to léonie
    Level 1 (0 points)
    Mar 8, 2016 1:20 PM in response to léonie

    Yep That's the ticket.

    My final script is this:

     

    set thisdate to the (current date) as date

    -- create a date object

     

    set thisday to the day of (thisdate as date)

    set thismonth to the month of (thisdate as date)

    -- return {thisday, this month}

     

    set thisDayAlbum to "On This Day"

    -- create an Album called On This Day

     

    tell application "Photos"

      try

      if exists container thisDayAlbum then

      delete the container thisDayAlbum

      delay 2 -- second try after delay

      end if

      make album named thisDayAlbum -- create a new, empty album

      on error errTexttwo number errNumtwo

      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 item i 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} to container thisDayAlbum

      end if

      on error errTexttwo number errNumtwo

      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 dialog theresultmessage

     

    I have set this to run every morning.

     

    The result is at breakfast, provided there are actually photos present, we can all watch the screen saver which will take pics from the "On This Day" Album... AWESOME thanks so much to you all for helping out.

     

    Now next steps, show the Location, Dates, and possibly the peoples names, garnered from the "faces" in each picture during a slide show...

     

    Screen Shot 2016-03-08 at 21.11.19.pngScreen Shot 2016-03-08 at 21.11.40.png

  • by léonie,

    léonie léonie Mar 8, 2016 1:32 PM in response to Solamanzi
    Level 10 (105,806 points)
    iCloud
    Mar 8, 2016 1:32 PM in response to Solamanzi

    Great idea to have this as a screensaver

     

    Now next steps, show the Location, Dates, and possibly the peoples names, garnered from the "faces" in each picture during a slide show...

    That part is not yet scriptable in Photos. 

    You can help by sending feedback to Apple, to add more scripting support to Photos, and make the slideshow themes more vrsatile.  Previously it was possible to use the metadata of the photos in the screensaver or in aslideshow, but that is not possible in Photos.

     

    The feedback form is here:   Apple - Photos - Feedback

    You could file a feature reqest or usability problem.

Previous Page 2