#! /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