We use cookies to provide you with a better experience. If you continue to use this site, we'll assume you're happy with this. Alternatively, click here to find out how to manage these cookies

hide cookie message

Emptying the trash automatically

Reader Collin Merrill would like to automate a common, but potentially risky, task on his Mac. He writes:

I was just wondering if you had an Automator workflow to automatically empty the trash. I'm fairly new to a Mac, and have almost no experience with Automator.

As you've likely noticed, while there is an Automator action for moving items to the trash (found in the Files & Folders area), there's no specific action for then emptying the trash. And that's a wise move on Apple's part as having such an action might lead to "Oh wait, I didn't mean to delete that!" situations.

But Automator's savvy designers have provided a workaround for things like this. And that workaround is AppleScript. While you may not be able to access an Apple-created Empty Trash action, you can build an AppleScript that accomplishes this task that's included as part of your workflow. I'll demonstrate by creating a workflow that only empties the trash when executed.

Launch Automator, choose the kind of workflow you want to create (in this case let's choose an Application workflow), and in the resulting window select the Utilities entry in Automator's first column and drag the Run AppleScript action to the workflow area to the right.

Highlight the text that reads (* You script goes here *) and enter:

tell application "Finder" empty the trash end tell

The entire content of that Run AppleScript action should now look like this.

Save your workflow to the desktop. Be sure there's something in the trash (and that you really want to empty the trash) and then double-click on your workflow to execute it. The trash will empty.

And that's the idea. When you can't find a way to accomplish one task or another with Automator's default tools, it's possible that you can do the job with AppleScript.

IDG UK Sites

Nexus 6 vs Sony Xperia Z3 comparison: Lollipop phablet takes on KitKat flagship smartphone

IDG UK Sites

Why people aren't upgrading to iOS 8: new features are for power users, not the average Joe

IDG UK Sites

Free rocket & space sounds: NASA launches archive of interstellar audio on SoundCloud

IDG UK Sites

iPad Air 2 review: Insanely fast and alarmingly thin. Speed tests, camera tests, beautiful...