Skip to content

Instantly share code, notes, and snippets.

@iUltimateLP
Created August 8, 2025 09:41
Show Gist options
  • Save iUltimateLP/eca739f63942adfded4bf4e681f8b391 to your computer and use it in GitHub Desktop.
Save iUltimateLP/eca739f63942adfded4bf4e681f8b391 to your computer and use it in GitHub Desktop.
Sometimes, WhatsApp images get their metadata removed, and the file date might be wrong. This exiftool command line parses the date from the filename (e.g. "IMG-20171028-WA0004.jpg"), and applies it to the metadata.
exiftool -overwrite_original ^
"-AllDates<${filename;m/IMG-(\d{4})(\d{2})(\d{2})/;$_=\"$1:$2:$3 12:00:00\"}" ^
"-FileModifyDate<${filename;m/IMG-(\d{4})(\d{2})(\d{2})/;$_=\"$1:$2:$3 12:00:00\"}" ^
"-FileCreateDate<${filename;m/IMG-(\d{4})(\d{2})(\d{2})/;$_=\"$1:$2:$3 12:00:00\"}" ^
IMG-*.jpg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment