I can no longer test in High Sierra, as my Mac is now running a newer system. How many photos have you selected, when you ran the script? It may have been timeout errors, when too many photos have been selected.
I'll try to add a different version of the script with more error checks.
Run it directly from the Script Editor.app. Paste the script into the editor, then select a few photos in Photos, then run press the "Run" button in Script Editor:
-- batch change the title of images to the filename
(* How to use this script:
Open this script in Script Editor. Launch Photos.
Select photos while viewing the "All Photos" album; this works better than Moments or smart albums
When all all photo are selected press the "Run" button in Scripteditor.
*)
set imageSel to {}
tell application "Photos"
activate
-- process the selected photos from the All Photos album
try
set imageSel to (get selection)
on error errTexttwo number errNumtwo
display dialog "Cannot get the selection: " & errNumtwo & return & errTexttwo
end try
-- check, if the album or the selected photos do contain images
if imageSel is {} then
error "Please select some images."
else
repeat with im in imageSel
try
tell im
set its name to its filename
end tell
on error errText number errNum
display dialog "Error: " & errNum & return & errText & "Trying again"
try
delay 2
tell im
set its name to its filename
end tell
on error errTexttwo number errNumtwo
display dialog "Skipping image due to repeated error: " & errNumtwo & return & errTexttwo
end try
end try
end repeat
end if
end tell
-- display dialog "Done"
return "Done"