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Â
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.