Last active
August 26, 2016 06:49
-
-
Save slant/84ab9528e2cecc03e88503a082af1eb6 to your computer and use it in GitHub Desktop.
Redate image files with original exif data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set the date of picture files to the EXIF date | |
function redate () { | |
# Replace spaces in filenames with underscores | |
echo "Removing spaces..." | |
for file in *; do mv "$file" `echo $file | tr ' ' '_'` ; done | |
# Get orginal date from EXIF data and update file's metadata dates | |
# Required: http://www.sno.phy.queensu.ca/~phil/exiftool/ | |
echo "Redating..." | |
find -E . -type f -iregex '.*\.(jpg|nef)' | while read PIC; do | |
echo "Redating $PIC" | |
DATE=$(exiftool -p '$DateTimeOriginal' $PIC | sed 's/[: ]//g') | |
echo "Date: $DATE" | |
echo "Command: touch -t $(echo $DATE | sed 's/\(..$\)/\.\1/') $PIC" | |
echo | |
touch -t $(echo $DATE | sed 's/\(..$\)/\.\1/') $PIC | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is necessary for pictures that are exported from an old Aperture or iPhoto or library. The file's Created and Modified datetimes are the date and time the pictures were exported. This script fixes that.