Created
June 19, 2023 14:35
-
-
Save wilik16/15335711be8e2b528f24d0b347be92e7 to your computer and use it in GitHub Desktop.
Almost similar with https://gist.github.com/wilik16/ce6f3e96b90fd459da661c4e22be3c91, but this one is based on the photo's exif instead of the csv file from icloud. Unfortunately this script is still incomplete but almost complete.
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
# frozen_string_literal: true | |
require 'exif' | |
require 'time' | |
folders = Dir.foreach('.').select do |e| | |
/^iCloud Photos/.match(e) | |
end | |
photos_paths = [] | |
folders.each do |folder| | |
photo_names = Dir.new("#{folder}/Photos").entries.reject do |e| | |
/(^.*\.csv$)|(^\.)|(^\.\.)/.match(e) | |
end | |
unless photo_names.empty? | |
photos_paths << "#{folder}/#{photo_names}" | |
end | |
end | |
return | |
file_path = 'iCloud Photos Part 48 of 50/Photos/IMG_5768-1.JPG' | |
# file_path = 'Photos/IMG_97721.JPG' | |
data = Exif::Data.new(File.open(file_path)) | |
puts data.date_time_original | |
puts data.date_time_digitized | |
puts data.offset_time | |
puts data.time_zone_offset | |
new_date = Time.strptime("#{data.date_time} #{data.offset_time}", '%Y:%m:%d %H:%M:%S %z') | |
puts new_date | |
puts File.mtime(file_path) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment