Clean your desktop; an applescript

Written on June 23, 2006 – 3:25 am | by James |

AppleScriptI really like how my mac simplifies and automates a lot of tasks, but one of the biggest things that irks me is all the junk that fills up my desktop after downloading and installing things. I generally keep my desktop clean (with no HD icon) except maybe one or two things that are currently important (and I keep these on the far left of the desktop, out of the way of all the detritus that builds up on the right). Using the wonders of applescript I wrote a simple script that will trash the files and folders that are on the right hand side of my desktop, but not the left hand side! Here’s how I did it.

AppleScriptI really like how my mac simplifies and automates a lot of tasks, but one of the biggest things that irks me is all the junk that fills up my desktop after downloading and installing things. I generally keep my desktop clean (with no HD icon) except maybe one or two things that are currently important (and I keep these on the far left of the desktop, out of the way of all the detritus that builds up on the right). Using the wonders of applescript I wrote a simple script that will trash the files and folders that are on the right hand side of my desktop, but not the left hand side!

Furthermore, I’ve setup a trigger in Quicksilver so I can press a simple key combo (I chose ^⌘Z) and have the script run instantly in the background. I’ve found this has solved the annoyance completely, if I have a lot of mess left over from downloads but there is one file I want to keep I just drag it a little to the left into the “safe-zone” and press ^⌘Z. You don’t have to use Quicksilver to trigger the script, there are many other programs that let you run a script from a key combo.

Of course, different people organise their desktops in different ways, but the nature of applescript means you can customise it to how you see fit. You can have a different part of your desktop become the “clean area” or you could set up exceptions for some files (or file types) you wish to keep safe. So without further ado, here is the script.

Help! What do I do with this script? First select all the blue text above and copy it to the clipboard (⌘C). Now go to your Applications folder and open up the AppleScript folder. Now run the Script Editor.app and paste the text into the new window (⌘V). Now you can save this script (name it whatever you please, and keep it in whatever folder you please). Now use one of the programs mentioned such as QuickSilver to trigger the script using your preferred keyboard shortcut.

IMPORTANT: Notice that this version of the script will trash all files and folders on the desktop that have an X-coord greater than 700 pixels. I have a 12″ PowerBook so my screen has 1024 horizontal pixels. If you have a higher resolution screen you may want to tweak this value.

DISCLAIMER: Since the files are only being trashed and not deleted then this script isn’t too dangerous, however I suggest that when you are experimenting with setting up the script to your liking that you don’t have any crucial files on your desktop. Furthermore, I cannot take any responsibility for any loss of data or damage caused by use of this script.

  1. One Response to “Clean your desktop; an applescript”

  2. By Joe Azzato on Sep 25, 2007 | Reply

    James,
    This is wonderful! Thanks a million. For years I’ve had a PowerBook desktop as cluttered as my real desktop. I usually make a folder called “Sort this” or something similar and drag everything to it and then to my external drive. I have dozens of these which I never get around to sorting. Your solution is great! I’ve installed it as is, and can invoke it with Quicksilver and it keeps my right side cleared off! yay!!! I’ll have to play with the script and see if I can get everything to move to my external drive when it’s attached, but that’s a future project.

    Thanks and Best regards!

    -Joe

Post a Comment

Find entries :