Creativity, Visibility, Design and Audio




Emptying the Trash Automatically using Automator’s

Category : Blog, Mac Tips · by Roxx Marino Feb 13th, 2012

Emptying the trash automatically

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:

[note_box]tell application “Finder”
empty the trash
end tell[/note_box]
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.

Macworld Weekly
Mac 911 Tip of the Week
By Christopher Breen at Macworld.com

 

SHARE :