Created
October 30, 2009 02:22
-
-
Save nummi/222039 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
require 'rubygems' | |
require 'rake' | |
task :extract do | |
extract_photos | |
end | |
namespace :extract do | |
task :test do | |
extract_photos(true) | |
end | |
end | |
def extract_photos(test_mode = false) | |
dir = File.dirname(__FILE__) | |
Dir.glob('*').each do |entry| | |
next unless File.directory?(entry) | |
Dir.chdir(entry) do | |
images = Dir.glob('*.{JPG,jpg,CR2,cr2}') | |
images.each do |image| | |
if test_mode | |
puts File.join(Dir.getwd, image) | |
next | |
end | |
old_path = Dir.getwd.gsub(' ', '\ ') | |
`cp #{File.join(old_path, image)} ~/Desktop/export/#{image}` | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment