Last active
August 29, 2015 14:01
-
-
Save mattpolito/aa3b65721e0412c8bce4 to your computer and use it in GitHub Desktop.
Update file creation dates from 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
#! /usr/bin/ruby | |
# requires exiftool: `brew install exiftool` | |
# Used to update file creation dates when converting RAW photos to JPG | |
# Converted files receive original file's EXIF data, but not file creation date. | |
# That date is set to whenever you created the converted file. | |
# Usage: `> ruby update_file_creation_date.rb ~/Pictures/converted_files/*.*` | |
files = ARGV | |
files.each do |file| | |
if file.match(/jpg/) | |
puts "*** #{file_path}" | |
timestamp = %x[exiftool #{file_path} -DateTimeOriginal -d %Y%m%d%H%M | awk '{print $4}'].strip | |
%x[touch -t #{timestamp} #{file_path}] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment