Dock Folder Launcher

Download Dock Icon

I’ve been using a stack on the Dock for my Downloads folder for a while now and sure, it’s pretty, but not terribly functional. You can open and drag files but that’s about it. What I want and I’m used to (in Windows) is an icon that opens the Downloads folder in Finder. I could use the Finder icon on the left of the dock, but there are two problems with that. First I would have to change the default location for new Finder windows, and I like having that as Applications. Second is that if you already have a Finder window open, clicking the icon just focuses that window instead of opening one in the default location.

Of course, I tried just dragging the folder onto the main dock area but it only accepts folders on that magical area to the right of the pedestrian crossing. And they show up as stacks. So I’ve come up with a quick and dirty workaround using AppleScript. Read on for the details.

Open Script Editor and paste the following code into a new script window. Note: you can type the command line break character using Option+Enter.

tell application "Finder"
	activate
	make new Finder window to folder ("Users:" & ¬
		(system attribute "USER") & ¬
		":Downloads") of startup disk
end tell

Compile the script, then run it to make sure it works.

Save the script as an Application Bundle called Downloads.app. You could save it as a standalone .app but it will have the crappy AppleScript icon and this is going on our dock so we want the icon to be something meaningful.

Save as Application Bundle

Locate the Application Bundle in Finder. These packages are really just folders, disguised as single files but you can easily crack them open. Right click Downloads.app and choose Show Package Contents which opens a new window.

In another Finder window, locate the icon file you want. In this example, we’re going to steal one of the Mac OS X system icons, which are found in /System/Library/CoreServices/CoreTypes.bundle. This is also a package, so go ahead and crack it open. Browse to the package’s Contents/Resources folder and locate the DownloadsFolder.icns file. Copy this (be sure not to move) into your Downloads.app/Contents/Resources folder. Delete the default applet.icns and rename DownloadsFolder.icns to applet.icns. Browse up a few levels and your application should now have the new icon.

Drag Downloads.app onto the dock and voila! A dock icon that opens Downloads in Finder! You can easily modify the script to open any folder, but AppleScript uses colons for the path separator instead of slashes for some bizarre reason. And “&” is the concatenation operator.

One behaviour I should implement in the future is: if there’s already a Finder window with the Downloads folder open, just focus it instead of opening a new one. But it’s good enough for now so I can wave goodbye to stacks.

Update 14 March 2009

Added support for “focus existing Downloads window if it exists”, code below.

Limitation: script only looks at window title, so you could have any “Downloads” folder open and it would focus that, regardless of the actual filesystem path.

-- Dock folder launcher version 1.1 (14/03/09)

-- Set options below
set launch_path to "Users:" & (system attribute "USER") & ¬
	":Downloads"
set focus_title to "Downloads"

-- Main script execution
set done to false
tell application "Finder"
	-- if we already have some windows
	if the (count of windows) is not 0 then
		-- examine each finder window
		repeat with i from 1 to count of Finder windows
			-- get the name
			set window_name to name of Finder window i
			-- if the title matches
			if window_name is focus_title then
				-- focus the application
				tell application "Finder"
					activate
				end tell
				-- activate the window
				activate Finder window i
				set done to true
				exit repeat
			end if
		end repeat
	end if
	if done is false then
		-- open new window
		tell application "Finder"
			activate
			make new Finder window to folder launch_path of startup disk
		end tell
	end if
end tell

Also, you can now download the app here: Downloads.app (Intel only).

About Si

Blog author
This entry was posted in Uncategorized and tagged . Bookmark the permalink.

2 Responses to Dock Folder Launcher

  1. Josh says:

    Or you could just right-click on the Downloads folder in the dock, and select “Open Downloads”?

  2. Si says:

    *Gasp* and waste valuable milliseconds?

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>