Skip to content

Instantly share code, notes, and snippets.

@ibressler
Created June 16, 2019 14:57
Show Gist options
  • Save ibressler/8684a6f97c6deb54b06a245eba3b0b88 to your computer and use it in GitHub Desktop.
Save ibressler/8684a6f97c6deb54b06a245eba3b0b88 to your computer and use it in GitHub Desktop.
fix exif metadata containing wrong keys and datetime with binary character
fn="$1"
echo "fn: $fn"
[ -f "$fn" ] || exit 1
str="$(exiv2 -p a "$fn" 2>&1 | grep -a Exif.Image.DateTime | grep -a -o '2019:.*$')"
#echo "'$str'"
# fix datatime first
exiv2 -M"set Exif.Image.DateTime $str" "$fn"
# extract all readable metadata (to .xmp file)
exiv2 -eaX "$fn"
# delete all metadata
exiv2 rm "$fn"
# restore metadata from file
exiv2 -iaX "$fn"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment