I am using this script below to change the titles, so the title will be prefixed with the filename.
The script copies just the first ten characters of the filename before the existing title, so the title will not become too long. To run the script, copy and paste it into the script editor window.
Then select a few photos in Photos (in the All Photos View or a top level album) and click the Run button in Script Editor.
Test first with only a few photos, preferably in a different Photos Library for testing. Ans always make a curreent backup of your library before trying scripts - better safe than sorry.
-- batch append the title of images to the filename (only the first ten characters of 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
set oldTitle to (the name of im) --as string
set oldTitleString to (the name of im) as string
set hasTitle to (oldTitle is not equal to missing value) and (the length of oldTitleString > 0)
if not hasTitle then
set oldTitle to ""
end if
set newtitle to characters 1 thru 10 of (the filename of im as string) as string
if hasTitle then
set newtitle to newtitle & " - " & oldTitleString
end if
-- return newtitle
try
tell im
set its name to newtitle
end tell
on error errText number errNum
display dialog "Error: " & errNum & return & errText & "Trying again"
try
delay 2
tell im
set its name to newtitle
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"