ExifTool Forum

ExifTool => Newbies => Topic started by: clem on March 21, 2022, 03:41:35 AM

Title: Rename & LR-compatible tagging based on filename
Post by: clem on March 21, 2022, 03:41:35 AM
As part of my tagging and sorting adventure I have found a tool that will extract and add a wee bit of information to the stripped-down images that Meta's WhatsApp generates when pics are transferred to have more data to work with than the initial date of saving attachment to drive.

So now I have a structured filename...

YYYY-MM-DD HH MM SS - WhatsApp Topic - hex/uuid suffix.filetypesuffix

ex:

2018-05-27 01 42 31 - Mary & Joe - 72eb0766-666f-491c-a86d-c7ab515051de.jpg
2021-06-30 21 44 51 - Picnic Plans - e724bcf0-7f19-4fe0-b564-0c892f07f4c6.jpg


So given that I'm using Lightroom as a Digital Asset Manager I'd like to change the files so that the dates LR picks up are not the filename creation / modified dates but rather EXIF based data and also have LR pick up on keywords in the XMP side if possible so that based on the file name it would have:


Is there a one-line version of this available to sic exiftool at the extracted attachments?

thank you!
Title: Re: Rename & LR-compatible tagging based on filename
Post by: StarGeek on March 21, 2022, 11:18:30 AM
To add the timestamps and as long as the format is as you show, you can copy the filename directly onto AllDates.  See FAQ #5 (https://exiftool.org/faq.html#Q5), paragraph starting "Having said this".

The rest will need some regex to pull the keywords out of the filename. Assuming there are no previous keywords in the file, which is likely since WhatsApp strips metadata, try
exiftool "-AllDates<Filename" "-Subject<${Filename;m/ - (.*?) - /;$_=$1}" -Subject=WhatsApp /path/to/files/

Example
C:\>exiftool -P -overwrite_original "-AllDates<Filename" "-Subject<${Filename;m/ - (.*?) - /;$_=$1}" -Subject=WhatsApp "Y:\!temp\bbb\2018-05-27 01 42 31 - Mary & Joe - 72eb0766-666f-491c-a86d-c7ab515051de.jpg"
    1 image files updated

C:\>exiftool -G1 -a -s -AllDates -Subject "Y:\!temp\bbb\2018-05-27 01 42 31 - Mary & Joe - 72eb0766-666f-491c-a86d-c7ab515051de.jpg"
[ExifIFD]       DateTimeOriginal                : 2018:05:27 01:42:31
[ExifIFD]       CreateDate                      : 2018:05:27 01:42:31
[IFD0]          ModifyDate                      : 2018:05:27 01:42:31
[XMP-dc]        Subject                         : Mary & Joe, WhatsApp