Download right into the Finder

Well, no real story behind this. The motivation just came from the need to combine downloading dl.tv episodes and drag’n dropping them from Finder to Disco ;-) ). So I wrote a little script that would download me a file right into the current folder in the front most Finder window.

on do_download(dl_file, dl_folder)
	tell application "Terminal"
		activate
		do script ("cd " & dl_folder & ¬
			"&& wget " & dl_file & " && exit")
	end tell
end do_download
tell application "Finder"
	set dl_folder to the front window's target as string
end tell
set dl_folder to quoted form of POSIX path of dl_folder
set dl_file to quoted form of (the clipboard as string)
display dialog "Download " & dl_file & "?"
if the button returned of the result is "OK" then
	do_download(dl_file, dl_folder)
end if

First of all: I’m sorry if this code is a little bit clumsy. This was basically my first AppleScript :-) And as you can see in the source code: it requires wget. Probably ugly, but it works ;-)

Ah, and btw.: Make sure there is something usable in your clipboard … like and URL. Otherwise starting this may mean the end of the universe. So basically and as always: Use this at your own risk. It does no checking at all simply because I normally know what’s in my clipboard … at least during the 2 seconds it takes me at maximum to get to the icon for this script in my dock after having copied an URL to the clipbaord ;-)

If you want this and don’t know, what to do with all this code:

  1. Open up your ScriptEditor (or something like that. I only have the German addition of MacOSX.)
  2. Paste the code into it
  3. Save it as “Application”

Then you can simply drop it (for example) in your Dock to make it easily accessible whenever you need it. And if you don’t have wget installed yet, get fink and fink install wget it :)