require 'rubygems' require 'exifr' mypix = Dir.glob(ARGV[0] +"/*.{jpg,JPG}") somepix = mypix.sort_by \
{ |a| EXIFR::JPEG.new(a).exif.to_hash[:date_time_original] } somepix.each do |pic_file| regex = /[\/\.]/ system("mv " + pic_file + " " +
pic_file.to_s.split(regex)[0] + "/" +
pic_file.to_s.split(regex)[0] + "_" +
EXIFR::JPEG.new(pic_file).exif.to_hash[:date_time_original].strftime("%Y-%m-%d_%H%M%S") +
".jpg") end
The run the app
$ruby rename_pix.rb trip12a
And now you can sort your pix.
No comments:
Post a Comment