Skip to content

Instantly share code, notes, and snippets.

@skyplor
skyplor / UpdateImageModifiedDate.sh
Created January 3, 2018 12:50
A bash script that will change the 'Last Modified Date' of an image file based on the filename. This is specifically for WhatsApp Images that comes in the format IMG-yyyyMMdd-WA0000.jpg
#!/bin/bash
for filename in *.jpg *.jpeg; do
echo $filename
IFS='-' read -ra fields <<< "$filename"
datefield=${fields[1]}
hour="00"
min="00"
touch -mt "$datefield$hour$min" $filename
done