It’s Time to Clean Up Your Mac Desktop
macOS
Summary
- You can hide desktop icons using a Terminal command, and use the same command to create a Shortcuts workflow that toggles the desktop on and off.
- You can automatically delete old files from the Desktop folder (or any folder) using Automator’s Folder Actions.
- Keeping your desktop clean can help you focus, while getting into the habit of moving important files to more permanent locations is good for organization.
Can’t stand looking at a messy Mac desktop? Fortunately you don’t have to. You can 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:
defaults write com.apple.finder CreateDesktop false
Then restart Finder using:
killall Finder
Your desktop icons are now hidden. Using the “four finger spread” show desktop gesture will still allow you to see 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.”
Now create a new Shortcut using the “+” plus icon. Add the “Run Shell Script” action and paste the following into the input field:
if $(defaults read com.apple.finder CreateDesktop);
then
defaults write com.apple.finder CreateDesktop false
else
defaults write com.apple.finder CreateDesktop true
fi
killall Finder
You can also add a “Show notification” action and type a short note, like “Desktop icons have been toggled!” if you want.
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 app HiddenMe to accomplish the same thing.
Automatically Delete Old Desktop Files
If you’d rather leave your desktop functionality in tact but instead automatically delete files, you can do that too. This is the same technique we’ve used to automatically 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.
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:
find ~/Desktop/ -ctime +30d -o -mtime +30d -iname '.'
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.
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 out some macOS Sequoia features that can make you more productive. Safari also has a neat new trick called Distraction Control which lets you clean up web pages.