Skip to content

Instantly share code, notes, and snippets.

@ohhdemgirls
Forked from windmillium/gist:8467188
Last active August 29, 2015 14:23
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 ohhdemgirls/20c3832c3330d37d15c3 to your computer and use it in GitHub Desktop.
Save ohhdemgirls/20c3832c3330d37d15c3 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# gem install tumblr_client
# use 'tumblr' command to generate security credentials
# fill in security info from the generated file at ~/.tumblr
# fill in the source directory and destintion directory
# fill in blogname
# script will upload a file then move it to the destination directory
require 'rubygems'
require 'tumblr_client'
Tumblr.configure do |config|
config.consumer_key = ""
config.consumer_secret = ""
config.oauth_token = ""
config.oauth_token_secret = ""
end
files = Dir["/home/username/tumblr_images/*"]
final_dir = "/home/username/queued_tumblr_images/"
blog = 'yourblog.tumblr.com'
# end variable section
client = Tumblr::Client.new
files.each do |file|
puts file
response = client.photo(blog, {:data => [file], :state => 'queue' })
if response.has_key?("errors")
puts response
exit 1
end
File.rename(file, final_dir + File.basename(file))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment