1

Picture (jpg) info has 3 dates/times: Created, Modified and Content Created How can I list the files in the Terminal showing Content Created, ls with any option only shows Created.

For info, I have a large amount of pictures taken by the kids from their travels, the only way to put them together chronologically is to sort them by the Content Created date/time.

1
  • What does "put them together" look like? Finder allows you to sort by filesystem creation date but I am guessing you have some reasons why you want this to be done in the terminal app or with a command-line tool...
    – bmike
    Nov 15, 2022 at 1:46

2 Answers 2

3

For photos mdls is the way to get at the detailed metadata.

mdls -name kMDItemContentCreationDate /path/to/file.jpeg
kMDItemContentCreationDate = 2022-11-14 14:57:22 +0000

You can choose other names like the filesystem creation date instead of the image creation date. For the image above, here are the dates I have on my Mac for an image I exported to the desktop from my iCloud photo stream of an iPhone image.

kMDItemContentCreationDate             = 2022-11-14 14:57:22 +0000
kMDItemContentModificationDate         = 2022-11-14 14:57:22 +0000
kMDItemDateAdded                       = 2022-11-15 01:42:29 +0000
kMDItemFSContentChangeDate             = 2022-11-15 01:42:29 +0000
kMDItemFSCreationDate                  = 2022-11-15 01:42:29 +0000
kMDItemLastUsedDate                    = 2022-11-15 01:42:29 +0000
0

Well, to list the files in a directory with their ContentCreationDate, navigate to the directory. The command uses ksh style extended globs. If your shell is ksh then you need to do nothing. If your shell is bash then you need to set the extended glob option-

 shopt -s extglob

If your shell is zsh then set the kshglob option

 set -o kshglob

The command is

 mdls -n kMDItemDisplayName -n kMDItemContentCreationDate -raw -nullMarker '-' +(*.jpg|*.JPG) | tr '\0' '\n' | paste - - 
2
  • That mdls command is excellent - thanks so much for the answer +1 indeed
    – bmike
    Nov 18, 2022 at 19:54
  • Thanks @bmike, I ‘m not quite sure why it got down voted.
    – fd0
    Nov 18, 2022 at 19:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .