Use date modified on Mac finder as date taken.

Started by cesarbattistini, December 26, 2020, 07:10:06 PM

Previous topic - Next topic

cesarbattistini

I need photos to recognize the date modified in finder, as the date taken of the photo.

Is this possible with ExifTool?

I have zero skills with this so if I could get a command line to just add the directory would be great!

Thank you in advance.

StarGeek

The trouble is figuring out what "Date Taken" is, because it's not the name of an actual tag.  It's a properly created by the OS.

Run this one one of the files, replacing /path/to/file/ with the actual file path
exiftool -time:all -G1 -a -s /path/to/file/

That will list all the time stamps in the file.  Look down the list and try and figure out which one is the current date taken and which one is the date modified.

From there, you would run a command like this, filling in the correct tag names
exiftool '-TagToCopyTo<TagToCopyFrom' /path/to/files
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

cesarbattistini

The correct one is FileModifyDate one now I can't find which one to replace so Photos will understand it

Thanks for the help!

Quote from: StarGeek on December 26, 2020, 07:24:25 PM
The trouble is figuring out what "Date Taken" is, because it's not the name of an actual tag.  It's a properly created by the OS.

Run this one one of the files, replacing /path/to/file/ with the actual file path
exiftool -time:all -G1 -a -s /path/to/file/

That will list all the time stamps in the file.  Look down the list and try and figure out which one is the current date taken and which one is the date modified.

From there, you would run a command like this, filling in the correct tag names
exiftool '-TagToCopyTo<TagToCopyFrom' /path/to/files

Alan Clifford

#3
I ran

mdls file.jpg

and got loads of stuff, including some dates, including

kMDItemContentCreationDate         = 2020-02-06 12:47:14 +0000
kMDItemContentCreationDate_Ranking = 2020-02-06 00:00:00 +0000
kMDItemContentModificationDate     = 2020-02-06 12:47:14 +0000

and more.

Not sure how to set these but I'll have a look now.  Sorry, but I don't use the "photos" application but maybe it uses one of the mditem dates?

StarGeek edit: Fixed duplicated [code] formatting

Alan Clifford

exiftool -s -api mditemtags=1 -MDItem*Date*  test.jpg

MDItemContentCreationDate       : 2020:02:29 11:16:11+00:00
MDItemContentCreationDate_Ranking: 2020:02:29 00:00:00+00:00
MDItemContentModificationDate   : 2020:02:29 11:16:11+00:00
MDItemDateAdded                 : 2020:12:26 19:43:35+00:00
MDItemDateAdded_Ranking         : 2020:12:26 00:00:00+00:00
MDItemFSContentChangeDate       : 2020:12:26 19:43:35+00:00
MDItemFSCreationDate            : 2020:12:26 19:43:35+00:00
MDItemGPSDateStamp              : 2020:02:29
MDItemInterestingDate_Ranking   : 2020:02:29 00:00:00+00:00

Alan Clifford

Most don't seem to be writable.

https://exiftool.org/TagNames/MacOS.html

You have do understand, I don't have a clue about what any of this!

Phil Harvey

Quote from: Alan Clifford on December 27, 2020, 08:12:59 AM
exiftool -s -api mditemtags=1 -MDItem*Date*  test.jpg

I'm wondering how you get away without quoting -MDItem*Date* on a Mac because the shell globbing should give you a "No match" error for this.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Alan Clifford

This worked on Linux (Raspberry Pi Raspian) as well as on the Mac.

alan@arcticus:~ $ exiftool -s -*date*time* ~/photographs/photo/2020/SouthAfrica.FebMar/x-s1_4120.jpg
DateTimeOriginal                : 2020:03:21 14:03:37
ProfileDateTime                 : 2009:02:20 17:07:10
GPSDateTime                     : 2020:03:21 12:03:37Z


Phil Harvey

What shell?

On Mac I use tcsh, although I think zsh is the default.   I just tried, and both of these give the error.  However, bash and sh do not.  Interesting.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Alan Clifford

Bash.  Experimenting, it changes behaviour if there is a file called -1date2time3.

cellini:testwhat3words alan$ exiftool -s -*date*time* test.jpg
DateTimeOriginal                : 2020:02:29 11:16:11
ProfileDateTime                 : 2009:02:20 17:07:10
GPSDateTime                     : 2020:02:29 09:16:11Z
cellini:testwhat3words alan$ cp test.jpg -1date2time3
cellini:testwhat3words alan$ exiftool -s -*date*time* test.jpg
cellini:testwhat3words alan$

Alan Clifford

Quote
   Pathname Expansion
       After word splitting, unless the -f option has been set, bash scans each word for the characters *, ?, and [.  If one
       of these characters appears, then the word is regarded as a pattern, and replaced with an alphabetically sorted  list
       of  file names matching the pattern.  If no matching file names are found, and the shell option nullglob is disabled,
       the word is left unchanged.  If the nullglob option is set, and no matches are found, the word is  removed.

With nullglob set, the -*date*time* string is removed it seems.

cellini:testwhat3words alan$ exiftool  -s -*date*time* test.jpg
cellini:testwhat3words alan$ shopt -s nullglob
cellini:testwhat3words alan$ exiftool  -s -*date*time* test.jpg
cellini:testwhat3words alan$ rm -- -1date2time3
cellini:testwhat3words alan$ exiftool  -s -*date*time* test.jpg
ExifToolVersion                 : 12.01
FileName                        : test.jpg
Directory                       : .
FileSize                        : 4.5 MB
FileModifyDate                  : 2020:12:26 19:43:35+00:00
FileAccessDate                  : 2020:12:27 15:06:51+00:00
FileInodeChangeDate             : 2020:12:26 19:43:35+00:00
FilePermissions                 : rw-r--r--
FileType                        : JPEG
FileTypeExtension               : jpg
MIMEType                        : image/jpeg
etc etc

StarGeek

Quote from: cesarbattistini on December 26, 2020, 08:36:29 PM
The correct one is FileModifyDate one now I can't find which one to replace so Photos will understand it

Ok, that's really strange for images that came from a camera.  There's no embedded timestamps at all, just the file system ones.

Try this
exiftool '-AllDates<FileModifyDate' /path/to/files/

Ah, I think I see the problem.  I think the WA indicates these are from WhatsApp, correct?  And that app strips away all metadata.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Phil Harvey

@Alan.  Interesting, thanks.  Learn something every day...  But I think I've hijacked this thread.  @StarGeek is keeping us honest though. :)

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).