ExifTool Forum

ExifTool => Newbies => Topic started by: cesarbattistini on December 26, 2020, 07:10:06 PM

Title: Use date modified on Mac finder as date taken.
Post by: cesarbattistini on December 26, 2020, 07:10:06 PM
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.
Title: Re: Use date modified on Mac finder as date taken.
Post by: 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
Title: Re: Use date modified on Mac finder as date taken.
Post by: 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

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
Title: Re: Use date modified on Mac finder as date taken.
Post by: Alan Clifford on December 27, 2020, 08:09:09 AM
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
Title: Re: Use date modified on Mac finder as date taken.
Post by: Alan Clifford on December 27, 2020, 08:12:59 AM
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
Title: Re: Use date modified on Mac finder as date taken.
Post by: Alan Clifford on December 27, 2020, 08:18:01 AM
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!
Title: Re: Use date modified on Mac finder as date taken.
Post by: Phil Harvey on December 27, 2020, 08:47:50 AM
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
Title: Re: Use date modified on Mac finder as date taken.
Post by: Alan Clifford on December 27, 2020, 09:26:26 AM
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

Title: Re: Use date modified on Mac finder as date taken.
Post by: Phil Harvey on December 27, 2020, 09:29:09 AM
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
Title: Re: Use date modified on Mac finder as date taken.
Post by: Alan Clifford on December 27, 2020, 09:56:51 AM
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$
Title: Re: Use date modified on Mac finder as date taken.
Post by: Alan Clifford on December 27, 2020, 10:14:41 AM
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
Title: Re: Use date modified on Mac finder as date taken.
Post by: StarGeek on December 27, 2020, 11:24:31 AM
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.
Title: Re: Use date modified on Mac finder as date taken.
Post by: Phil Harvey on December 27, 2020, 03:48:22 PM
@Alan.  Interesting, thanks.  Learn something every day...  But I think I've hijacked this thread.  @StarGeek is keeping us honest though. :)

- Phil