Skip to content

Instantly share code, notes, and snippets.

@mattpolito
Last active August 29, 2015 14:01
Show Gist options
  • Save mattpolito/aa3b65721e0412c8bce4 to your computer and use it in GitHub Desktop.
Save mattpolito/aa3b65721e0412c8bce4 to your computer and use it in GitHub Desktop.
Update file creation dates from exif data
#! /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