Skip to content

Instantly share code, notes, and snippets.

@campanalbero
Created September 23, 2013 17:14
Show Gist options
  • Save campanalbero/6673860 to your computer and use it in GitHub Desktop.
Save campanalbero/6673860 to your computer and use it in GitHub Desktop.
カレントフォルダのJPGファイルのEXIFを読み取って、 yyyy-mm-dd 形式のフォルダを作って、 そこにJPGファイルを移動する
require 'rubygems'
require 'exifr'
Dir.glob('*.JPG') do |f|
exif_time = EXIFR::JPEG::new(f).date_time_original
yyyymmdd = exif_time.strftime('%Y-%m-%d')
Dir::mkdir(yyyymmdd) unless FileTest.exist?(yyyymmdd)
File.rename(f, yyyymmdd + '/' + f)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment