Script: Batch Changing the Titles to the Filename w/Extension 2018
The predecessor to Photos "iPhoto" used the filenames as default titles and has shown the filenames below the thumbnails in the browser. Photos 1.0 to Photos 3.0 do not show the filenames as titles, and if a photo has no title, there is no identification visible in the browser, only in the Info panel.
This has been changed in Photos 4.0 on macOS 10.14. Photos 4.0 and Photos 5.0 can show the filenames in albums, the moments, and the All Photos view, but they are not really titles, and we cannot select and copy and paste them. The Photos 4.0 and 5.0 fake filename titles are dimmed.
To batch change the titles of photos without title, to make them visible below the thumbnails as real titles, that can be copied and pasted, you could try an Automator script I wrote to bring the titles back:
Enable the option "View > Metadata > Titles" in Photos, if it is not enabled.
Create an Automator action, that executes an Apple Script to change the titles to the filename, if the title is empty:
- Launch Automator, create a new service, and drag a "Run Apple Script" action into the workflow.
- Copy and paste the text below into the "Run Apple Script" action to replace the default text in the action.
on run {input, parameters}
tell application "Photos"
activate
set imageSel to (get selection)
if imageSel is {} then
error "Please select an image."
else
repeat with im in imageSel
set title to the name of im
if not (exists (title)) then
set the name of im to the filename of im
end if
end repeat
end if
end tell
return input
end run
It should look like this:
Save this workflow with a suitable name. It will be installed in the services.
- Now launch Photos and select a few test images.
- Open the "Photos Menu > Services".
- The service should be shown in the menu - I saved my version as "filename2title".
- Select the service to let it run. When you click the selected photos again, the titles should change.
After the Automator action completed:
My script will just give you the general idea how to access filename and title in an Apple Script. For a more elaborate AppleScript, with more error checks and removing the filename extension, check out the script that NicFletcher posted:
A sample AppleScript and some technical observations on Photos
For a discussion on how to improve this script, see: Re: Re: Where are photo file names?
Re: Re: Where are photo file names?
An old version of this User Tips with more comments is here:
Script: Batch Changing the Titles to the … - Apple Community
And here is a link to a compiled version as an application on Old Toad's tutorial site:
http://www.oldtoad.net/PHOTOS%20File%20Name%20to%20Title.app.zip