The script could be found in https://gist.github.com/joerick/a68ecc083e4dbcedb8737f6a5b524ef5
-- create a folder for use by the script and set the path to it here
set thepath to alias "Macintosh HD:Users:joerick:Desktop:Scratch" as text
tell application "Photos"
set photos to every media item of container "DateFix"
repeat with mediaitem in photos
tell application "Finder" to delete every item of folder thepath
export {mediaitem} to thepath with using originals
tell application "Finder" to set theExport to item 1 of folder thepath
set theCommand to "/opt/homebrew/bin/exiftool -S -DateTimeOriginal " & (quoted form of POSIX path of (theExport as alias))
set exifOutput to do shell script theCommand
set resultDate to the current date
-- set theyear to (text 19 thru 22 of exifOutput)
-- set themonth to (text 24 thru 25 of exifOutput)
-- set theday to (text 27 thru 28 of exifOutput)
-- set thehours to (text 30 thru 31 of exifOutput)
-- set theminutes to (text 33 thru 34 of exifOutput)
-- set theseconds to (text 36 thru 36 of exifOutput)
--
-- return theyear & themonth & theday & thehours & theminutes & theseconds
set the year of resultDate to (text 19 thru 22 of exifOutput)
set the month of resultDate to (text 24 thru 25 of exifOutput)
set the day of resultDate to (text 27 thru 28 of exifOutput)
set the hours of resultDate to (text 30 thru 31 of exifOutput)
set the minutes of resultDate to (text 33 thru 34 of exifOutput)
set the seconds of resultDate to (text 36 thru 36 of exifOutput)
set the date of mediaitem to resultDate
end repeat
end tell