How can I use ExifTool to set all photos in a folder to the earliest capture date?

Asked 12/4/2017

4 views

2 answers

0

I need all images in one folder to share the same date stamp for delivery. For example, a concert started late on 04.12.2017 and ran past midnight into 05.12.2017, but the agency wants every image labeled with the earlier date.

Is there a way with ExifTool to read the dates from all files in a directory, find the earliest one, and then write that date back to every file in the set? If the dates already match, nothing should change.

Originally by Photography Stack Exchange contributor. Source · Licensed CC BY-SA 4.0

Photography Stack Exchange contributor

8y ago

2 Answers

1

This is the solution. It also contains imprivements to the original script.

#!/bin/tcsh -f


# remove all Umlaute
exiftool -L -overwrite_original -api "Filter=s/ä/ae/g;s/ö/oe/g;s/ü/ue/g;s/Ä/Ae/g;s/Ö/Oe/g;s/Ü/Ue/g;s/ß/ss/g" -TagsFromFile @ -all:all .


# add ", " to the caption:

exiftool '-caption-abstract<${caption-abstract}, ' .

# set all dates to the earliest date
set earliest_date="`exiftool -DateCreated -fileorder DateCreated -q -s3 . | head -1`"
set latest_date="`exiftool -DateCreated -fileorder DateCreated -q -s3 . | tail -1`"

if ( "$earliest_date" == "$latest_date" ) then
   echo "checked date"
else
   echo "earliest date is $earliest_date and latest date is $latest_date"
   echo "setting DateCreated to $earliest_date and TimeCreated to unknown"
   exiftool -DateCreated=$earliest_date .
   exiftool -TimeCreated="00:00:00" .
endif

Originally by user50598. Source · Licensed CC BY-SA 4.0

user50598

8y ago

0

AI Answer

Generated from our catalog & community — verify before relying on it.

Yes, but this is best done with a small shell script rather than a single ExifTool one-liner.

The approach shown in the community answer is:

  1. Read DateCreated from all files.
  2. Sort by that tag using -fileorder DateCreated.
  3. Take the first value as the earliest date.
  4. Optionally compare it with the latest date.
  5. If they differ, write the earliest DateCreated to all files and set TimeCreated to 00:00:00 (or another neutral value).

Example logic:

  • exiftool -DateCreated -fileorder DateCreated -q -s3 . | head -1 gets the earliest date.
  • ... | tail -1 gets the latest date.
  • If different, run ExifTool again to write the chosen date to the whole folder.

The posted solution also improves the workflow by using -overwrite_original and combining multiple text-replacement filters into one command.

So: yes, ExifTool can do this reliably, but using a script to capture the earliest date first is the practical solution.

UniqueBot

AI

8y ago

Your Answer