Skip to content

Instantly share code, notes, and snippets.

@usagizmo
Last active July 7, 2016 07:31
Show Gist options
  • Save usagizmo/68073683f44f1e2678a1 to your computer and use it in GitHub Desktop.
Save usagizmo/68073683f44f1e2678a1 to your computer and use it in GitHub Desktop.
写真ファイルの作成日/更新日のメタ情報をファイル名から置換する
# coding: utf-8
require 'find'
require 'time'
Find.find 'files' do |f|
if File.basename(f).match /\d{4}-\d{2}-\d{2} \d{2}\.\d{2}\.\d{2}/
originaltime = Time.parse File.basename(f, File.extname(f)).gsub '.', ':'
File.utime File.atime(f), originaltime, f unless originaltime.nil?
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment