Skip to content

Instantly share code, notes, and snippets.

@nummi
Created October 30, 2009 02:22
Show Gist options
  • Save nummi/222039 to your computer and use it in GitHub Desktop.
Save nummi/222039 to your computer and use it in GitHub Desktop.
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