Apple’s Worldwide Developers Conference to kick off June 10 at 10 a.m. PDT with Keynote address

The Keynote will be available to stream on apple.com, the Apple Developer app, the Apple TV app, and the Apple YouTube channel. On-demand playback will be available after the conclusion of the stream.

You can make a difference in the Apple Support Community!

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

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

How to sort photos by date taken in finder?

How to sort photos by date taken in finder?

NOT date created, date modified etc...

MacOS Mojave up to date

Mac mini, macOS 10.14

Posted on Mar 3, 2020 1:55 AM

Reply
Question marked as Best reply

Posted on Mar 3, 2020 9:06 AM

If the photo image originated from a camera that has embedded EXIF or XMP data within the photo, then copying the file from the camera directly to the Mac will use the EXIF DateTimeOriginal timestamp from the image as its creation date that is shown in the Finder. If the photo does not directly originate from a camera, but is transferred between different computers, or over the Internet, the Finder may not use the internal EXIF data when assigning a creation date.


So, the Finder cannot see the internal EXIF DateTimeOriginal time stamp in a collection of images to sort them, only the creation date. This can be solved programmatically with some effort, or by third-party software that can see the EXIF data and sort accordingly.

9 replies
Question marked as Best reply

Mar 3, 2020 9:06 AM in response to edenbensal

If the photo image originated from a camera that has embedded EXIF or XMP data within the photo, then copying the file from the camera directly to the Mac will use the EXIF DateTimeOriginal timestamp from the image as its creation date that is shown in the Finder. If the photo does not directly originate from a camera, but is transferred between different computers, or over the Internet, the Finder may not use the internal EXIF data when assigning a creation date.


So, the Finder cannot see the internal EXIF DateTimeOriginal time stamp in a collection of images to sort them, only the creation date. This can be solved programmatically with some effort, or by third-party software that can see the EXIF data and sort accordingly.

Mar 3, 2020 2:47 PM in response to edenbensal

Yes.


Dock : Launchpad : Other : Script Editor.


Copy/paste the following (next post) AppleScript into the editor and click the hammer icon, followed by run. Select multiple images by depressing the command key. A dialog will appear with image names sorted top down by oldest to newest DateTimeOriginal values.



You can Save As… a double-clickable script (.scpt), script bundle (.scptd), or application (.app) to your Desktop for future usage. I would recommend saving what you have copied/pasted as Text (.applescript) which is your source code.

Mar 3, 2020 12:31 PM in response to VikingOSX

I have just written an AppleScript that provided the image is .jpg, or Camera RAW (e.g. tested with Nikon Z7 .NEF), it will allow you to select multiple files and then sort them from oldest to newest filename based on their internal EXIF DateTimeOriginal date stamp. It then lists these top down, oldest to newest, in a display dialog by filename.


Even with this sorted list, telling Finder to reveal the items in the sorted list defaults to filesystem dates on these images, and it ignores the sorted DateTimeOriginal filename order.

Mar 3, 2020 2:45 PM in response to VikingOSX

-- sort selected jpg image files by their EXIF DateTimeOriginal data, and display top down
-- from oldest to newest by filename.

use framework "Cocoa"
use AppleScript version "2.4" -- Yosemite 10.10 or later
use scripting additions

property NSBitmapImageRep : a reference to current application's NSBitmapImageRep
property NSDictionary : a reference to current application's NSDictionary

set keys to {} as list
set values to {} as list
set tmp to {} as list
set valid_types to {"public.jpeg", "public.camera-raw-image"}
set imgFiles to (choose file default location (path to pictures folder) of type valid_types with multiple selections allowed)

repeat with anImg in imgFiles
	set exifdata to my readEXIFdata(anImg)
	if not class of exifdata is boolean then
		copy anImg to the end of keys
		copy DateTimeOriginal of exifdata to the end of values
	else
		log "no-op"
	end if
end repeat

-- sort by DateTimeOriginal values
set nsd to NSDictionary's dictionaryWithObjects:values forKeys:keys
set foo to (nsd's keysSortedByValueUsingSelector:{"localizedStandardCompare:"}) as list

tell application "Finder"
	set {TID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, return}
	repeat with anItem in foo
		copy (name of item anItem) to the end of tmp
	end repeat
	display dialog (items of tmp) as text with title "DateTimeOriginal Ordered Images"
	set AppleScript's text item delimiters to TID
end tell
return

on readEXIFdata(img)
	-- Reference: Shane Stanley, MacScripter 2015-11-12
	-- https://macscripter.net/viewtopic.php?id=44419
	set imgRep to NSBitmapImageRep's imageRepWithContentsOfFile:(POSIX path of img)
	set _exifdata to imgRep's valueForProperty:(current application's NSImageEXIFData)
	if not _exifdata is missing value then
		return _exifdata as record
	else
		return false
	end if
end readEXIFdata


Mar 5, 2020 3:22 AM in response to edenbensal

I did not experience that error in my testing. What kind of file caused this? The following (separate) AppleScript will dump the entire EXIF record in the Result section of the Script Editor. Use the image that caused the error above, and see what is shown for DateTimeOriginal in it.


use scripting additions
use framework "Foundation"
use framework "AppKit" -- for image stuff

set valid_types to {"public.jpeg", "public.camera-raw-image"}

set POSIXPath to POSIX path of (choose file of type valid_types default location (path to pictures folder))

return my readEXIFFromJpeg:POSIXPath


on readEXIFFromJpeg:POSIXPath
	set theImageRep to current application's NSBitmapImageRep's imageRepWithContentsOfFile:POSIXPath
	set theEXIFData to theImageRep's valueForProperty:(current application's NSImageEXIFData)
	if not theEXIFData is missing value then
		return theEXIFData as record
	else
		return false
	end if
end readEXIFFromJpeg:


I may have to add a test for the existence of DateTimeOriginal before attempting to add it to the values list. A DateTimeDigitized may also be used as well.

How to sort photos by date taken in finder?

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