Upload Photos.app/Contents/MacOS/rename-photos.rb
# Return the date/time on which the given photo was taken.
Return the date/time on which the given photo was taken.
Return the date / time on which the given photo was taken .
def photo_date(file)
  output = `sips -g creation "#{file}"`.chomp.split(/\n/)[1]
  if output.nil? || output =~ /error|<nil>/i
    File.mtime(file)
  else
    date = output.sub(/^\s*creation:\s*/, '')
    DateTime.strptime(date, "%Y:%m:%d %H:%M:%S")
  end
rescue => e
  puts "#{e}: #{output}"
  File.mtime(file)
end
def photo_date ( file ) output = ` sips -g creation " #{ file } " ` . chomp . split ( / \n / ) [ 1 ] if output . nil? || output =~ / error|<nil> /i File . mtime ( file ) else date = output . sub ( / ^ \s *creation: \s * / , '' ) DateTime . strptime ( date , "%Y:%m:%d %H:%M:%S" ) end rescue => e puts "#{e}: #{output}" File . mtime ( file ) end
Return the date/time on which the given photo was taken.
Return the date / time on which the given photo was taken .
# fallback to file date
file
<not_specific>