Hi,
I'd started with a script that included the extensions but then realised that I'd rather remove them. Possibly a little late in the day for you but this is my variation on the theme:
tell application "Photos"
activate
set updated to 0
set info to "Photos | Filename to Title"
set images to (get selection)
if images is {} then
display dialog "Please select items in Photos before calling this script." with titleinfobuttons {"OK"} giving up after 5
else
repeat with image in images
set title to the name of image
if not (exists (title)) or title = "" then
set revTitle to (reverse of (characters of the filename of image)) as string
set pos to offset of "." in revTitle
set prefix to (reverse of (characters (pos + 1) thru -1 of revTitle)) as string
set the name of image to prefix
set updated to updated + 1
else
set revTitle to (reverse of (characters of title)) as string
set pos to offset of "." in revTitle
set prefix to (reverse of (characters (pos + 1) thru -1 of revTitle)) as string
set postfix to (reverse of characters 1 thru (pos - 1) of revTitle) as string
if (offset of postfix in "jpg|mov|png") > 0 then -- Extend list as required
set the name of image to prefix
set updated to updated + 1
end if
end if
end repeat
if updated = 1 then
set message to " item was updated."
else
set message to " items were updated."
end if
if updated = 0 then
set message to "No" & message
else
setmessageto(updated as string) & message
end if
display dialogmessagewith titleinfobuttons {"OK"}
end if
end tell
This will add the filename without the extension as an image title, or remove any extension currently included in the title. I haven't caught up with all of the discussions but it seems that Photos can sometimes bomb out when running the script on large numbers of items, and it may be more reliable when running the script with the contents of an Album rather than the global photos collection.
tt2