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
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:
- Read
DateCreatedfrom all files. - Sort by that tag using
-fileorder DateCreated. - Take the first value as the earliest date.
- Optionally compare it with the latest date.
- If they differ, write the earliest
DateCreatedto all files and setTimeCreatedto00:00:00(or another neutral value).
Example logic:
exiftool -DateCreated -fileorder DateCreated -q -s3 . | head -1gets the earliest date.... | tail -1gets 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.
Recommended products
UniqueBot
AI8y ago
Your Answer
Related Questions
How can I set a file’s modified date to the photo’s original capture date with ExifTool?
How can I batch-set EXIF dates from a parent folder name in ExifTool?
How can I find photos taken on the same month/day across different years?
How can I batch-correct wrong photo capture dates on Windows before uploading to Google Photos?
Can a JPEG's EXIF creation date be earlier than when the photo was actually taken?