Last active
July 7, 2016 07:31
-
-
Save usagizmo/68073683f44f1e2678a1 to your computer and use it in GitHub Desktop.
写真ファイルの作成日/更新日のメタ情報をファイル名から置換する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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