I am looking for a way to use exiftool to extract the date of creation from the pictures in a directory and just in case they differ, use the earliest date. The application case is a concert that runs from 04.12.2017:20:00 until 05.12.2017:00:20. My agency want all pictures from the set to have the same day stamp. So it should say 04.12.2017 on all pictures. I guess there is a cleaver one-liner to do this. Is there?
Edit: As suggested in the comments, this has to be done by a script. This is the shell script I have so far.
#!/bin/tcsh -f
# remove Umlaute
exiftool -L -api "Filter=s/ä/ae/g" -TagsFromFile @ -all:all .
exiftool -L -api "Filter=s/ö/oe/g" -TagsFromFile @ -all:all .
exiftool -L -api "Filter=s/ü/ue/g" -TagsFromFile @ -all:all .
exiftool -L -api "Filter=s/Ä/Ae/g" -TagsFromFile @ -all:all .
exiftool -L -api "Filter=s/Ö/Oe/g" -TagsFromFile @ -all:all .
exiftool -L -api "Filter=s/Ü/Ue/g" -TagsFromFile @ -all:all .
exiftool -L -api "Filter=s/ß/ss/g" -TagsFromFile @ -all:all .
# extend caption by ", ":
exiftool '-caption-abstract<${caption-abstract}, ' .
#set date to earliest date in the set
exiftool -T -DateCreated .
# clean up
rm *.jpg_original
Edit 2:
This is the solution:
#!/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
head
will give you the earliest value. Assign that to a variable.exiftool -DateCreated -fileorder DateCreated -q -s3 . | head -1
Then, take that and assign that to all the filesexiftool -DateCreated =$VAR .
\$\endgroup\$-api "Filter=s/ä/ae/g;s/ö/oe/g;s/ü/ue/g;s/Ä/Ae/g;s/Ö/Oe/g;s/Ü/Ue/g;s/ß/ss/g"
When you want to add a new one, just add it on the end, separated with a semicolon. \$\endgroup\$-overwrite_original
to your commands. For example,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 .
\$\endgroup\$