Skip to content

Instantly share code, notes, and snippets.

@watsonbox
Created December 15, 2014 16:23
Show Gist options
  • Save watsonbox/fec4ed2a3ac7a4dfb998 to your computer and use it in GitHub Desktop.
Save watsonbox/fec4ed2a3ac7a4dfb998 to your computer and use it in GitHub Desktop.
Scans a folder of photos looking for save timestamps in XMP header
#! /usr/bin/env ruby
#
# Scans a folder of photos looking for save timestamps in XMP header
#
require 'nokogiri'
dir = ARGV[0]
Dir.foreach(dir) do |file|
next if file[0] == '.'
xmp = Nokogiri::XML(`exiftool -xmp -b "#{File.join(dir, file)}"`)
xmp = xmp.xpath(
"//x:xmpmeta/rdf:RDF/rdf:Description/xmpMM:History/rdf:Seq/rdf:li",
'xmpMM' => "http://ns.adobe.com/xap/1.0/mm/",
'x' => 'adobe:ns:meta/',
'rdf' => "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
)
xmp.each do |element|
if element['stEvt:when']
puts "#{file}, #{element['stEvt:when']}"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment