Even the most organized among us will still end up with a cluttered Desktop from time to time. You never intend for things to get out of control, but before you know what’s happening, you’ve got a Desktop full of downloads and screenshots, and you're hooking your laptop up to a projector with thirty casual acquaintances from work about to see just how many cat gifs you’ve got downloaded. You could throw everything into a random folder, but then you have a folder full of junk.
It would be great if you could just hide all of that mess temporarily but then get all of your files back, wouldn’t it? That’s just what we’re going to do. In this tutorial, we’ll use Automator to create a set of Desktop-cleaning AppleScripts that run from the Finder menu. Our first script will hide everything on your Desktop, and the second will put it all back!
Create the Hide Desktop Script
Open up Automator, found in your Applications folder. Choose Service as your new Automator document type. This is important, because while we’ll be using an AppleScript to perform the action, we’re going to run the AppleScript from the Services menu in Finder.
At the top of the main workflow pane, select “no input” for the first dropdown. In the second dropdown, you’re going to select “Finder.” The text at the top of the main workflow pane should now read, “Service receives no input in Finder.”
Next, find the Run AppleScript action in the left pane, available under Utilities. The easiest way to find this or any other action in Automator, though, is to use the search field. When you’ve got the Run AppleScript action, drag it to the main workflow pane.
You’ll find the action will already have the bones of an AppleScript, but we’re not going to use that. Instead, delete everything in the script field and replace with the following:
on run do shell script "chflags hidden ~/Desktop/*" end run
Save your Automator service with your freshly edited AppleScript. Give it a good name, something like “Hide Desktop.”
Tip: You can go ahead and run your AppleScript from Automator to make sure it works by clicking the green button, but without the accompanying unhide script we'll create next, you won't be able to retrieve your icons, yet.
Create the Unhide Desktop Script
That’s great! You can hide everything, but we don’t have a way to unhide your Desktop icons.
To do that, create a new service in Automator, just as above. This is going to be the same as before, so in the main workflow pane, again select “no input” and “Finder” in the two dropdowns.
Drag the Run AppleScript action to the main workflow pane, and delete the default script. This time, you’re going to paste a slightly different AppleScript in its place:
on run do shell script "chflags nohidden ~/Desktop/*" end run
Save your second Automator service, and name it something to go with the first, like “Unhide Desktop.”
Exit Automator, and you’re done.
Test Your New Services
You probably want to check if your services actually work, though, and that’s not a bad idea. If you have any open applications, minimize everything until all you see is your Desktop. Remember you’re testing whether the service will hide icons on your Desktop, so if you’ve managed to clear everything off of there already, nothing much is going to happen. You can still try out your service after creating a few empty folders on your Desktop, though.
Click Finder in the menu bar and hover over the Services menu. You should get a flyout with all of your available services, though what’s there may vary depending on what apps you have installed and running.
Select Hide Desktop (or whatever you named the service to clean up your Desktop icons). All of the icons on your desktop will disappear. If it doesn’t happen immediately, just give the service a second to do its job.
With all of your Desktop icons hidden, we can now test the second service. Locate the Services menu in Finder again, but this time click Unhide Desktop. After a moment, all of your Desktop icons will reappear.
In this tutorial, we created two AppleScripts for hiding all the files you have hanging out on your Desktop. Our first script whisks everything away, and the second script puts all of it back like nothing ever happened. We used Automator to create services, so that our scripts would always be accessible in the Finder menu.
This is a great solution if you’re loaning your computer out or expect anyone else to see your Desktop and don’t want to die of shame when they see the state of it. It also temporarily protects sensitive files from prying eyes but isn’t a long term security solution.
How do you deal with the all the files that seem to crop up on your Desktop? Let us know in the comments!
Envato Tuts+ tutorials are translated into other languages by our community members—you can be involved too!Translate this post