TUAW Tip: Take control of your sidebar
Today's tip is all
about your Finder sidebar. I've altered mine a bit from the default setup to better accommodate the way I work. The
first thing I do is to remove the Movies, Music and Pictures folders. They're really only a single click away from my
home folder, plus I use iTunes to manage my music and videos, and iPhoto handles my photos. So I rarely need to go
poking around those folders manually. To remove a folder or other item from your sidebar, simply click and drag it out
of the list, then let go and it's gone.Next, I've brought in my current projects. To add an item to the sidebar, simply click and drag it into place. A thin, blue line appears between existing items. Drop it in and you're all set.The four folders you see below my "Documents" folder contain the files that are currently receiving all of my attention. Now they're only a click away, no matter where I've navigated to in the Finder.
The "Trash" is actually a super simple Apple Script that reads:
on open
tell the application "Finder"
move the selection to the trash
end tell
end open
I saved my script as an application, moved it to my "Documents" folder, gave it a sweet icon from The Iconfactory and dragged it into my sidebar. Anything dropped onto it will be moved to the trash. Finally, my Quickdrop folder is where I store all the junk that I accumulate during the day (I like a clean desktop). At the end of the day, I decide what I want to keep from in there, move those items to their proper locations and send the rest to the trash.

![TUAW [Cafepress]](http://www.blogsmithmedia.com/www.tuaw.com/media/tuaw-cafepress-promo.png)


Reader Comments (Page 1 of 2)
djones said 11:35AM on 2-03-2006
I can't help but think that there is some drawback or potentially harmful result of using that Applescript instead of using Finder's built in methods for trashing things.
You can still have the functionality without having to move out of the window, either by using the Action menu dropdown and selecting Move to Trash, or by customizing your Finder toolbar and adding the Delete icon. It's the one that looks like a big "no" sign.
Reply
atFault said 11:54AM on 2-03-2006
Why would there be a harmful result in using a script that simply _moves_ the file to the .trash and nothing else?
Here's another question, it's easy enough to drag the Network icon/button out of the top section of the sidebar, and it does disappear, but I can't for the life of me figure out how to get it back. Dragging from the folder instance at the top of the window or at the root level of the drive does not place it back in the sidebar. Any idea how?
Reply
Dave Caolo said 11:58AM on 2-03-2006
atFault: Yes. While in the Finder, go to Preferences in the Finder menu, and select the "Sidebar" tab.
Reply
atFault said 12:03PM on 2-03-2006
@ Dave Caolo,
Wow, thanks, I never thought to look there. Since you can drag stuff in and have it stay and drag stuff out and have it poof I completely forgot that was in there. Goes to show, even hardcore Mac users can overlook the seemingly obvious.
Reply
Doug Adams said 12:10PM on 2-03-2006
AppleScript is cool and all, but what's wrong with Command-Delete for trashing Finder selections?
Reply
eddie said 12:16PM on 2-03-2006
I don't see a problem with using the apple script. It is using "Finder's built in methods for trashing things". The script is telling Finder to trash the items.
I do prefer using the keyboard shortcut though.
Reply
djones said 12:32PM on 2-03-2006
"Why would there be a harmful result in using a script that simply _moves_ the file to the .trash and nothing else?"
For one, since a script is parsing it instead of the Finder itself, when deleting large numbers of files (like say, a .App), there might be a performance difference. Secondly, I don't think that's the proper way to handle multiple Finder selections in Applescript. I seem to recall from my AppleScripting days that you should assign the selection to an array, and then use a for/next loop to traverse the array items individually. I don't have time at the moment to verify this or to find out why, but it is striking a chord in my mind.
Either way, as I mentioned, there are two non-scriptable solutions that use the mouse, for those that don't like cmd-delete. Why would you choose a scripted solution over something built into the OS?
Reply
Sean Flanagan said 12:44PM on 2-03-2006
I'd like to add another tip to this for those of us who try to maintain a super-organized machine:
1. Place a folder on the Desktop underneath the drive icons and name it with a non-breaking space (Option-Space), effectively giving it the appearance of no name at all
2. Change the icon to a transparent icon created by copying a square transparent PNG and pasting on top of the icon in the Get Info... window
3. Drag the now-invisible folder to the sidebar to create a spacer
It also acts as a spacer between drive icons and printers (or anything else) on the desktop even when Cleaning Up the desktop. If you want more spacers, you can repeat the same process, adding non-breaking spaces for each additional folder you create.
Reply
Doug Adams said 12:45PM on 2-03-2006
The only thing lethal about the script is if you don't happen to notice you have selected something you don't want to trash. Otherwise, the syntax is correct.
Reply
James Huston said 12:46PM on 2-03-2006
Here's a better Trash Applescript I just whipped up to replace the toolbar delete button.
If you have a Finder selection it moves that selection to the trash. If you have no selection it will open the Users trash folder, something I miss having in the toolbar. It also supports dragging files to the icon to move them to the trash. It works around a bug where every column view has a selection, regardless of if its visible or not.
---
on open these_items
tell application "Finder" to delete every item of these_items
end open
on run
set TrashPath to path to trash from user domain
tell application "Finder"
set FileSelection to selection
set CurrentTarget to target of window 1
set SelectionCount to count of FileSelection
if SelectionCount = 0 or (item 1 of FileSelection) = CurrentTarget then
open TrashPath
else if (item 1 of FileSelection) ≠ CurrentTarget then
tell application "Finder" to delete every item of FileSelection
end if
end tell
end run
---
Reply
djones said 12:54PM on 2-03-2006
Thanks Doug, I must just have that lodged in my brain from Finder scripts that change info or names of a selected group of files, which obviously requires processing each individually.
Reply
djones said 12:57PM on 2-03-2006
Thanks Doug, I must have lodged in my brain all of the Finder scripts that add / change info or names of selected items, which obviously have to be parsed individually.
Reply
Chris L W said 2:23PM on 2-03-2006
Another way to add the user Trash folder is to sinply...
Go to Spotlight and search for .trash,
When .Trash (the folder) comes up in the search, click show all,
in Spotlight's browse window, drag the .Trash folder to your sidebar.
I haven't figured out how to change the bland folder to a icon of choice, however. It's system level. Maybe someone out there has the answer?
Just my .02
Reply
Andy said 2:58PM on 2-03-2006
I may be a bit thick here but how do you get your icons that small in the sidebar?
I have tried reducing the icon size in view options but this only changes the size of the window icons
Reply
Thomas said 3:09PM on 2-03-2006
Personally I don't keep my iTunes stuff in Music anyway, with the addition of podcasts and video content it irks me. I've created a Media folder (coulda just used iTunes I suppose but that felt restiricting) so use that, now my music folder can be used for stuff not for iTunes etc.
Reply
Dave said 3:21PM on 2-03-2006
James: Very cool! Thanks for posting it.
Reply
jonas Zimmermann said 5:28PM on 2-03-2006
this applescript actually proved to be harmful to me: i was deleting objects in my 'downloads' folder, when i got a message that some objects couldn't be deleted because they were already in trash. i didn't believe it, opened the trash folder (from the dock), and indeed, the files didn't show in the list. i couldn't move the files into the trash manually either, so i decided to empty the trash. just to see that my whole downloads folder was gone. it wasn't shown in the trash folder either. couldn't recover the files, had a backup from a couple of weeks ago, though. :(
Reply
Jan Peters said 5:30PM on 2-03-2006
This can be done easier: just creat a symbolic link with
ln -s ~/.Trash Trashbin
or something like that and drag it to the side.
Reply
Zach said 6:25PM on 2-03-2006
I spotlighted ".trash" and dragged the result into the sidebar. I hit "apple + i" to get info. Then, I renamed the item from ".trash" to "trash". Also, I changed the image from the bland photo to a .jpeg of a wire waste basket. It appeared to work- I could drag items into the trash from the finder. However, I cannot empty trash anymore. I have tried emptying the trash from the dock icon, in the finder, and from finder dropdown window. I am rather anxious that I inadvertantly harmed my computer, for the inability to empty trash is rather bothersome, and perhaps it has as yet unknown implications. Please, can someone help me? (P.S. I tried renaming it ".trash" but that is restricted, as ".trash" is reserved by the system. Please, please, please help me. Thank you in advance.
Reply
James Huston said 6:48PM on 2-03-2006
Fixed my script to work around predictable but wrong column view behavior.
---
on open these_items
tell application "Finder" to delete every item of these_items
end open
on run
set TrashPath to path to trash from user domain
tell application "Finder"
set FileSelection to selection
set CurrentTarget to target of window 1
set SelectionCount to count of FileSelection
if SelectionCount = 0 then
open TrashPath
else if (item 1 of FileSelection) ≠ CurrentTarget then
delete every item of FileSelection
else if (item 1 of FileSelection) = CurrentTarget and current view of window 1 = column view then
set FolderName to name of item 1 of FileSelection
display alert "Delete "" & FolderName & ""?" message "Due to a column view limitation would you like to delete "" & FolderName & "" or do nothing?" as warning buttons {"Cancel", "Delete"} default button "Delete" cancel button "Cancel"
if button returned of the result is "Delete" then
delete every item of FileSelection
end if
end if
end tell
end run
---
Reply