Skip to content

Instantly share code, notes, and snippets.

@qoobaa
Last active December 31, 2016 11:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qoobaa/b14cf7ab71528e860dc819a34a6476ab to your computer and use it in GitHub Desktop.
Save qoobaa/b14cf7ab71528e860dc819a34a6476ab to your computer and use it in GitHub Desktop.
require "open-uri"
require "fileutils"
open("attachments.csv").each do |line|
path, url = line.split(",", 2)
puts path
FileUtils.mkdir_p(File.dirname(path))
open(path, "w") { |f| f.write(open(url).read) } unless File.exist?(path)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment