Summary

Can’t stand looking at a messy Mac desktop? Fortunately you don’t have to. you’re able to either hide everything for effortless zen, or automatically move old files to the trash after a set period. Here’s how.

Hide Everything on Your Desktop

Why deal with a mess if you can just hide it? This might not be the best way to live your life, but if you demand a squeaky clean desktop instantly without losing a single file then it’s the perfect trick for you.

You can do this with the following Terminal command:

Then restart Finder using:

Your desktop icons are now hidden. Using the “four finger spread” show desktop gesture will still allow you tosee your desktop widgets. You can reverse the command by replacing “false” with “true” and restarting Finder again.

A shortcut that allows you to toggle your desktop on and off is even more useful. To do this, open the Shortcuts app and click Shortcuts > Settings > Advanced then toggle on “Allow Running Scripts.”

Enable scripts in Shortcuts settings.

Now create a new Shortcut using the “+” plus icon. Add the “Run Shell Script” action and paste the following into the input field:

You can also add a “Show notification” action and type a short note, like “Desktop icons have been toggled!” if you want.

A Shortcuts workflow for toggling the macOS desktop on or off.

Now give your Shortcut a name at the top of the window, and click on the icon to change that too. Next, click on the “i” information button on the right and enable “Pin in Menu Bar” if you want to trigger it from the menu bar. You could even use the “Add Keyboard Shortcut” to trigger it with a custom key combination (consider using a hyper key for this).

I use this all the time to capture nice clean desktop screenshots (but I’ve fallen into the trap of just having the desktop disabled most of the time). If you don’t fancy messing around with Terminal commands and Shortcuts, you can use the $1.99 appHiddenMeto accomplish the same thing.

Toggle hiding and showing the macOS desktop using Shortcuts.

Automatically Delete Old Desktop Files

If you’d rather leave your desktop functionality in tact but instead automatically delete files, you’re able to do that too. This is the same technique we’ve used toautomatically delete files from the Downloads folder, so make sure you give it a read if you want more in-depth steps.

This trick involves using Automator’s Folder Action functionality, which triggers each time you add a new file to the Desktop.

Creating a new Folder Action with Automator.

To get started, launch Automator and use the “New Document” option to create a new Folder Action. When prompted, select your “Desktop” folder for the “Folder Action receives files and folders added to” prompt.

Now add the “Run Shell Script” action to your workflow, making sure to select the “/bin/bash” shell from the drop-down. Below that, paste the following command:

Grant access to your Desktop folder within Automator.

This will find all files created (-ctime) and modified (-mtime) within the last 30 days (30d) with any filename or extension (.). Feel free to change this to be longer or shorter. Click the “play” button at the top of the window to run the script, then observe the results in the “Results” box. Be aware that folders are included too.

You’ll need to grant Automator access to the folder in question.

An Automator folder action that deletes files from the desktop after 30 days.

Finally, add a “Move to Trash” action beneath this action to link the two. Hit Command+S or use File > Save to save your Folder Action. You’re done! Remember you’ll still need to empty the trash, and that the action won’t trigger until something is added to the folder.

Get into the habit of moving important things off the desktop so you never need to worry about what gets deleted.

Or Clean Up Everything Manually

You don’t need me to tell you to clean your room, but here I am doing it anyway. Personally, I find a clean desktop helps me think. Unclutter your workspace to unclutter your mind, or something like that.

If you have trouble staying focused, you might want to check outsome macOS Sequoia features that can make you more productive. Safari also has a neat new trick calledDistraction Control which lets you clean up web pages.