You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Script: Batch Change the Date and Time to a Fixed Date

by: 
Last modified: Mar 4, 2019 11:47 AM
18 7799 Last modified Mar 4, 2019 11:47 AM

iPhoto had the very convenient Batch Change tool to set the date and time of all selected photos to a fixed date, with a time increment added between successive photos. This was very convenient for older photos, that had no capture date embedded. This batch change option is missing in Photos. Here is a little Apple Script, that can be run to batch change the dates like in iPhoto. If you still have iPhoto installed, simply use iPhoto to batch change dates.

My script can be used to change the dates directly in Photos.


User uploaded file

To copy and paste it copy all text from the gray codeblock into a Script Editor window.

(* Batch change the time of selected photos all at once 

How to use this script:
- Collect all photos you want to set to the same time in an album 
- and sort them manually
- Adjust the time of the first of your batch of photos with 
  "Adjust Date and time" in Photos from the "Image" menu, 
 even if the time is correct
- Select first the photo with the adjusted date, 
- the hold down the Shift key and select all photos you want 
  to set to the same date and time at once. 
- You need to select at least two photos.
- Open this script and run it by pressing the "Run" button.
- The script will copy the date from the first image 
  and set all photos to the same date, 
  and step the date by adding the increment 
  given by the variable timeIncrement.
- The script will return the last date it changed

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

Note - for some photos it may not be possible to change the time, 
then running "Adjust date and time" for all photos once may help. 
Photos has a bug that displays timezones incorrectly, 
so the results may look wrong, 
if the photos have been taken in different timezones.

This script has been tested in Photos version 1.0 to 4.0, 
with MacOS X 10.10.3 - macOS 10.14.2
 
© Léonie
*)


set timeIncrement to 1 -- the time increment in minutes
(* select at least 2 images in Photos *)
tell application "Photos"
	activate
	set imageSel to (get selection)
	if (imageSel is {}) or (the length of imageSel < 2) then
		error "Please select at least two images."
	else
		
		set first_image to item 1 of imageSel
		set first_date to (the date of first_image) as date
		repeat with i from 2 to count of imageSel
			
			set next_image to item i of imageSel
			set next_date to (the date of next_image) as date
			
			set time_difference to (first_date - next_date) ¬
				+ ((i - 1) * timeIncrement * minutes)
			--	return time_difference -- testing
			
			tell next_image
				set the date of next_image to (next_date + time_difference) as date
			end tell
			
		end repeat
	end if
	return "Adjusted the date and time of " & (the length of imageSel) ¬
		& " photos. The last date is " & ((the date of next_image) as date)
end tell


The previous, deprecated version of the script is here: (Old ASC: Script: Batch Change the Date and Time to a fixed Date)



The script can be downloaded from Old Toad's Tutorial site as a compiled application.

See this link:

http://oldtoad.net/ASC/Batch%20Change%20the%20Date%20and%20Time%20to%20a%20Fixed%20Date.zip


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