Robo

Dropbox in Snow Leopard (part deux revisited)

Posted in Applescripts by Robin Ramael on October 9, 2009

A few weeks ago I posted an applescript that could be used in an automator-service to automativally upload a file to your public dropbox and copy the URL to your clipboard. You can find that post here)

The problem with that original applescript was that it only worked with filenames without spaces, which isn’t very handy. After a long search on how to fix this in applescript i realized that I’m quite a dumbass for not just doing it in sed. I then added three lines to the original script and proceeded insulting myself in various languages.

The dropboxmover script 1.1:

(*
This applescript copies the selected file to the dropbox public folder and copies the URL to the clipboard and is intented for use within an automation. (created for Mac OSX 10.6 Services)
Created by Robin Ramael on 29th of august 2009
No rights reserved whatsoever

FILL IN YOUR DROPBOX USER ID BELOW!!!!
*)

on run {input, parameters}

	--FILL IN YOUR DROPBOX USER ID HERE
	set userid to 244025

	set dropboxpath to (path to home folder) & "Dropbox:Public:" as string

	--Check if filesize isn't too big
	get size of (info for input)
	set filesize to result / 1000000
	if filesize is greater than 50 then
		say "woaw"
		display dialog "This file is " & warningsize & " MB, are you sure you want to upload it to Dropbox?" with icon caution
	end if

	--Copy file
	tell application "Finder"
		duplicate input to folder dropboxpath with replacing
		--Get the name of the file to put in clipboard later in the automation
		set filename to name of (info for input)
	end tell

	--make the filename URL suitable
	set filename to (do shell script "echo \"" & filename & "\" | sed -e 's/\\ /%20/g'")
	set dURL to "http://dl.getdropbox.com/u/" & userid & "/" & filename as string

	return dURL
end run

Thanks to monototo from the comments for helping out

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

Gravatar
WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.