Convert Create Date and Write to Title

Started by klind, August 23, 2024, 12:17:17 AM

Previous topic - Next topic

klind

I've been using Exiftool for several years and I find it a great asset. However I recently decided to make some changes to my MacOS Photos Library of many tens of thousands of photos. Currently I have all my photos sorted by filename with the filenames in the following general format:

YYYY-MM-DD ~[Person or subject] ~ConflictResolutionNumber

For example:

1995-07-06 ~Ken ~01
1995-07-06 ~Ken ~02
1996-01-01 ~Ken

And so on...

I would like to add a Title to the Exif metadata that mimics the filename after converting the date in the filename to a more standard Month Day, Year format while omitting the conflict resolution number data. For example, using the above displayed information:

July 6, 1995 ~Ken
July 6, 1995 ~Ken
January 1, 1996 ~Ken

I already know how to write the title information, how can I expedite this process (to any extent) as there are a great many files involved?

I am open to any and all suggestions.

Regards,

Ken
Ken Lind

Phil Harvey

Hi Ken,

This comes close:

exiftool "-title<${basename;DateFmt('%b %d, %Y')} ${basename;s/ ~\d+$//;s/.* (~.*)/$1/}" DIR

It writes XMP title with the format you requested, with the exception that the month day will have 2 digits:

eg. "Jul 06, 1995 ~Ken".

- 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 ($).

StarGeek

For the full month name, you would use %B instead of %b

Lifting a regex from one of my earliest questions, you could remove the leading 0 with
exiftool "-title<${basename;DateFmt('%B %d, %Y');s/\b0//;} ${basename;s/ ~\d+$//;s/.* (~.*)/$1/}" DIR

C:\>exiftool -P -overwrite_original "-title<${basename;DateFmt('%B %d, %Y');s/\b0//;} ${basename;s/ ~\d+$//;s/.* (~.*)/$1/}" "Y:\!temp\x\y\1995-07-06 ~Ken ~01.jpg"
    1 image files updated

C:\>exiftool -G1 -a -s -title "Y:\!temp\x\y\1995-07-06 ~Ken ~01.jpg"
[XMP-dc]        Title                           : July 6, 1995 ~Ken

Things get a bit off if "ConflictResolutionNumber" reaches 24, though. I think the remaining number is shifting the number of hours, so each additional multiple of 24 gains an additional day
C:\>exiftool -P -overwrite_original "-title<${basename;DateFmt('%B %d, %Y');s/\b0//;} ${basename;s/ ~\d+$//;s/.* (~.*)/$1/}" "Y:\!temp\x\y\1995-07-06 ~Ken ~23.jpg"
    1 image files updated

C:\>exiftool -P -overwrite_original "-title<${basename;DateFmt('%B %d, %Y');s/\b0//;} ${basename;s/ ~\d+$//;s/.* (~.*)/$1/}" "Y:\!temp\x\y\1995-07-06 ~Ken ~24.jpg"
    1 image files updated

C:\>exiftool -G1 -a -s -title Y:\!temp\x\y
======== Y:/!temp/x/y/1995-07-06 ~Ken ~23.jpg
[XMP-dc]        Title                           : July 6, 1995 ~Ken
======== Y:/!temp/x/y/1995-07-06 ~Ken ~24.jpg
[XMP-dc]        Title                           : July 7, 1995 ~Ken
    1 directories scanned
    2 image files read

Which could be fixed by adding s/ ~\d+$//; before the DateFmt
C:\>exiftool -P -overwrite_original "-title<${basename;s/ ~\d+$//;DateFmt('%B %d, %Y');s/\b0//;} ${basename;s/ ~\d+$//;s/.* (~.*)/$1/}" Y:\!temp\x\y
    1 directories scanned
    2 image files updated

C:\>exiftool -G1 -a -s -title Y:\!temp\x\y
======== Y:/!temp/x/y/1995-07-06 ~Ken ~24.jpg
[XMP-dc]        Title                           : July 6, 1995 ~Ken
======== Y:/!temp/x/y/1995-07-06 ~Ken ~70.jpg
[XMP-dc]        Title                           : July 6, 1995 ~Ken
    1 directories scanned
    2 image files read
"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

...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 ($).

klind

Wow! More data then I expected. Thanx to the extreme to both of you. Exiftool and this forum are the best!
Ken Lind