Skip to content

Instantly share code, notes, and snippets.

Last active June 4, 2023 13:50
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Bash script for setting exif photo date according to filename. Created for whatsapp images can be easily adjusted for every filename patterns.
set -e #Exit as soon as any line in the bash script fails
for filename in *.jpg
#extracting info from file name
#setting exif timestamp into file
exiv2 -M"set Exif.Image.DateTime $year:$month:$day" $filename
#set the file last modified timestamp
touch -t "$year$month$day""1500" $filename
echo "successfully set the correct timestamp in $imageCounter images"
Copy link

Hi federicoB,

  • We need Storing session data in DynamoDB on Magento
    Please help me.

Copy link

nkuk377 commented Dec 22, 2022

I was trying to sort this problem out and found this code which helped me a lot. It worked like charm without changing anything.
I have 100-s of photos with right date-time on their names, but wrong in exif data.
I tried to modify this code to set the "time" stamp as in the photo's name, but could not make it work.
I stuck on error: "touch: invalid date format ‘20220412 200618’"
The example file I am trying this on is "IMG_20220412_200618.jpg"
I declared 3 more variables: $hour, $min, $sec, then tweak around, but no luck.
Please, give me a clue how to implement this.
Thanks for your code =)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment