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
hash = Hash.new() | |
Dir.glob(File.expand_path(ARGV[0]) + '/**/*') do |f| | |
if File.ftype(f) == "file" | |
ext = File.extname(f) | |
arr = hash[ext] | |
if arr == nil | |
arr = Array.new() | |
end | |
hash.store(ext, arr.push(f)) | |
end |
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
require 'set' | |
set = Set.new() | |
Dir.glob(File.expand_path(ARGV[0]) + '/**/*') do |f| | |
if File.ftype(f) == "file" | |
ext = File.extname(f) | |
set.add(ext) | |
end | |
end |
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
require 'rubygems' | |
require 'sequel' | |
require 'pp' | |
DB = Sequel.sqlite('photo.db') | |
failures = DB[:failure] | |
# insert into failure (path) values ('/path/to/photo.file'); | |
failures.insert(:path => '/path/to/photo.file') |
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
require 'rubygems' | |
require 'sequel' | |
require 'pp' | |
DB = Sequel.sqlite('photo.db') | |
dataset = DB[:photos] | |
# どちらでも同じ | |
# select * from photos where model = 'NIKON D40'; | |
pp dataset.filter(:model => 'NIKON D40').first |
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
require 'rubygems' | |
require 'sequel' | |
require 'pp' | |
DB = Sequel.sqlite('photo.db') | |
dataset = DB[:photos] | |
pp dataset.first | |
# dataset.first は order by がなくてもうまくいが dataset.last は order を指定してないと怒られる理不尽仕様 | |
pp dataset.order_by(:date_time_original).last |
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
require 'rubygems' | |
require 'sequel' | |
require 'pp' | |
DB = Sequel.sqlite('photo.db') | |
items = DB["select * from photos where datetime(date_time_original) > datetime('2014-01-01 00:00:00')"].all | |
pp items |
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
Dir.glob(FROM + '**/*').sort{|a, b| a <=> b}.each do |f| | |
puts f | |
end | |
# 順場関係なしに全部出力したいだけなら以下の通り | |
# Dir.glob(FROM + '**/*') do |f| | |
# puts f | |
# end |
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
require 'mini_exiftool' | |
exif = MiniExiftool.new(TO_FILE) | |
exif.copy_tags_from(FROM_FILE, 'all') | |
exif.save |
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
require 'rubygems' | |
require 'mini_exiftool' | |
Dir.glob(['*.NEF']) do |f| | |
photo = MiniExiftool.new(f) | |
puts photo.DateTimeOriginal | |
end |
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
require 'digest/md5' | |
hash = Hash.new {} | |
Dir.glob('*') do |f| | |
digest = Digest::MD5.file(f).to_s | |
if hash[digest] == nil then | |
hash.store(digest, f) | |
else | |
hash.store(digest, hash[digest] + ", " + f) | |
end | |
end |