Created
July 5, 2010 15:24
-
-
Save therabidbanana/464461 to your computer and use it in GitHub Desktop.
A script to copy dropbox review urls to clipboard
This file contains hidden or 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
#!/usr/bin/env ruby | |
# dont change anything below, unless you know what are you doing | |
require 'fileutils' | |
require 'cgi' | |
require 'base64' | |
class DropboxThingy | |
DROPBOX_URL="http://review.orangesparkleball.com/" | |
def initialize | |
@dropbox_url = DROPBOX_URL | |
end | |
def process_files(filenames) | |
urls = [] | |
filenames.each do |file| | |
urls << process_file(file) | |
end | |
return urls | |
end | |
private | |
# finds single review url | |
def process_file(filename) | |
basename = File.basename(filename) # just the name of file | |
dirs = File.dirname(filename).split('/').reverse | |
path = CGI::escape(basename).gsub( /\+/, '%20') | |
# Find all dirnames not == OSB Review | |
for dir in dirs | |
if dir == 'OSB Review' | |
break | |
else | |
dir = CGI::escape(dir).gsub( /\+/, '%20') | |
path = "#{dir}/#{path}" | |
end | |
end | |
# encoded filename | |
url = @dropbox_url + path | |
return url | |
end | |
end | |
dd = DropboxThingy.new | |
filenames = ARGV | |
urls = dd.process_files(filenames) | |
u = urls.join("\n" ) | |
exec( "printf \"#{u}\" | pbcopy" ) # -n prevents newline being appended |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment