Photos sorted by date

I am trying to get my photos to sort by date. I asked AI to create a script for me but Apple says there is an error "Expected “,” but found identifier." Can anyone fix? Chatgpt can't fix it and I don't know anything about writing scripts



tell application "Photos"

set selectedAlbum to (get selection)

if selectedAlbum is {} then

set allImages to media items of every album

else

set allImages to media items of every album whose name is name of item 1 of selectedAlbum

end if

set sortedImages to (sort allImages by date)

repeat with thisImage in sortedImages

set creationDate to (get (media item date thisImage))

set creationYear to year of creationDate as text

set creationMonth to month of creationDate as integer

set creationDay to day of creationDate as integer

set yearAlbum to (get album named creationYear)

if yearAlbum is missing value then

set yearAlbum to make new album with properties {name:creationYear}

end if

set monthAlbum to (get album named ((text -2 thru -1 of ("0" & (creationMonth as text))) & " - " & (month of (creationDate as date) as text)))

if monthAlbum is missing value then

set monthAlbum to make new album with properties {name:((text -2 thru -1 of ("0" & (creationMonth as text))) & " - " & (month of (creationDate as date) as text)), parent:yearAlbum}

end if

set dayAlbum to (get album named (text -2 thru -1 of ("0" & (creationDay as text))))

if dayAlbum is missing value then

set dayAlbum to make new album with properties {name:(text -2 thru -1 of ("0" & (creationDay as text))), parent:monthAlbum}

end if

add thisImage to dayAlbum

end repeat

end tell

MacBook Pro (M2, 2022)

Posted on Mar 14, 2023 2:17 PM

Reply
7 replies

Mar 16, 2023 8:01 AM in response to Artie_rabbit

Unfortunately the metadata has lots of dates-- captured, created, and modified seem to mean different things to different software (and there may be different versions of even those in the metadata.)


For pictures like this, I use the app GraphicConverter ($40, but with useful free demo period to let you check it out) to transfer the captured dates to dates that Finder and Photos will use before importing them to Photos. (Be careful with apps that claim to do this inside of Photos -- they will probably make a mess of the library!) GraphicConverter is so useful it is always open, and it is the default for opening pictures on my Mac. And when I have problems, my questions are always answered promptly.

Mar 15, 2023 2:33 PM in response to Artie_rabbit

Hello Artie_rabbit,


This page can help out with viewing Photos app content by date: Browse your photos in Photos on Mac - Apple Support


Browse your photos by days, months, or years
1. In the Photos app  on your Mac, click Library in the sidebar.
2. In the toolbar, click one of the following:
Years: Quickly go to a specific year in your photo library.
Months: View photos grouped by month, and organized by the days or the location they were taken.
Days: View photos taken on the same day.
All Photos: View all of your photos and videos at the same size, in chronological order.
The Photos window showing Days selected in the toolbar and photos organized by date appearing in the main area of the window.
3. Double-click a day, month, or year to see the photos in it.
On a trackpad, you can pinch open or closed on the day, month, or year to change views.


Cheers.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Photos sorted by date

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