⚙️ Change image creation date to last modified date
During image organisation I stumbled upon some images which had some invalid file system dates. These had a creation date which was younger than the last modified date.
Maybe some backup process had overwritten the original creation date. Normally this would be no problem when the EXIF snapshot date would be set. But these images are all from different sources and not one hold EXIF data. The only remaining way would be now to set the creation date to the last modified date (which was thankfully the same as the original creation date).
After some research the
touch command can set the creation date. The date command retrieves the last modified date and
touch sets it as creation date.
touch -t $(date -r image.jpg "+%Y%m%d%H%M") image.jpg
With a short bash script this automatically performs the action for a whole folder.
#!/bin/bash for i in *.*; do echo $i touch -t $(date -r $i "+%Y%m%d%H%M") $i done
⚠️ Please be sure to execute the script in the right folder, no warranty if something bad happens