Script: Batch Changing the Title to the Capture Date, 2018

by: 
Last modified: Nov 4, 2019 6:51 AM
2 2501 Last modified Nov 4, 2019 6:51 AM

If you want to be able to display the date below the thumbnails of your photos, consider to batch change the titles to the capture date using an Apple Script.


This simple script will read the dates from selected photos and set the title of the photo to the date string. Open the Script Editor and paste this in:


(* Batch change the titles of the selected photos to the capture time

How to use this script:
- Select all photos you want to change the title of in Photos
- Open this script and run it by pressing the "Run" button in the toolbar.
- The script will read the capture date from the selected images and create a short date string 
   according to the system preferences for the short date format in 
   System Preferences > Language & Region > Advanced
- The script will return the last date of the last photo it changed

- if you save this script as an Application you can add it to the Dock and run it from there

This script has been tested in Photos version 1.0 to 4.0, with MacOS X 10.10.3 to macOS 10.14.2

© Léonie
*)

(* select at least 1 image in Photos *)
tell application "Photos"
	activate
	set imageSel to (get selection)
	if (imageSel is {}) then
		error "Please select at least one image."
	else
		repeat with i from 1 to count of imageSel
			set next_image to item i of imageSel
			set capture_date to (the date of next_image)
			set short_capture_date_string to the short date string of capture_date
			set capture_time_string to the time string of capture_date
			set new_title to short_capture_date_string & " @" & capture_time_string
			tell next_image
				set the name of next_image to the new_title as text
			end tell
		end repeat
	end if
	return ¬
		"Adjusted the titles of " & (the length of imageSel) ¬
		& ¬
		" photos. The last date is " & ((the date of next_image) as date)
end tell



Then select the photos from your most recent import in Photos and click the "Run" button in the toolbar of Script Editor.


The script should look like this in the Script Editor:

It will format the date like in the short date format set in System Preferences > Language & Region > Advanced. The date and Time part will be separated by a "@". if you want a different separation character, change it in line 27 - replace "@" by the character you really want to use:

			set new_title to short_capture_date_string & " @" & capture_time_string
		

Previous version from the old ASC: Script: Batch Changing the Title to the Capture Date


The script can be downloaded from Old Toads Tutorial site:

http://oldtoad.net/ASC/Batch%20Change%20Title%20to%20the%20Capture%20Date-2018.zip


Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.