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.

Revisions

  1. mattpolito revised this gist May 12, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion update_file_creation_date_from_exif.rb
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@
    # 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/*.*
    # Usage: `> ruby update_file_creation_date.rb ~/Pictures/converted_files/*.*`

    files = ARGV
    files.each do |file|
  2. mattpolito revised this gist May 12, 2014. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions update_file_creation_date_from_exif.rb
    Original file line number Diff line number Diff line change
    @@ -6,6 +6,8 @@
    # 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/)
  3. mattpolito created this gist May 12, 2014.
    16 changes: 16 additions & 0 deletions update_file_creation_date_from_exif.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    #! /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.

    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