Skip to content

Instantly share code, notes, and snippets.

@calavera
Created June 16, 2012 21:50
Show Gist options
  • Save calavera/2942610 to your computer and use it in GitHub Desktop.
Save calavera/2942610 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
require 'fileutils'
FileUtils.mkdir('images') unless File.directory?('images')
Dir.glob("source/_posts/*.markdown").each do |post|
content = File.read(post)
images = content.scan(%r{(http://ieatcupcakes.com/wp-content/.+\.jpg|png|jpeg)})
images.flatten.each do |image|
puts "Downloading #{image}"
Dir.chdir('images') { `curl -O #{image}`}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment