Creating an Automated Job to Empty the Trash in Keyboard Maestro

Each Friday, I like to tidy up my machine before turning it off for the weekend. This includes several maintenances tasks including emptying the Trash. Like a real trashcan, why leave it sit?

With Keyboard Maestro, this becomes an automated task. With one code block, the trash can be emptied on a schedule. There is no need for me to remember. No need to switch apps. No need to accept a confirmation prompt.

As you can see from the screenshot, the Trigger is set to At Time. Since this is for my home machine, I have this set for 7:45PM each Friday. The one at work is set for 3:00PM. As long as the machine is turned on and I’m logged in, the macro will run. And come on, who isn’t logged into their at 7:45 on a Friday night?

The next block of the macro is the small piece of AppleScript it takes to empty the Trash. It’s job is to turn off the confirmation prompt, empty the trash, then turn the prompt back on.

While this is a simple macro, it takes the task off my plate. I don’t have to spend time thinking about it. I won’t get distracted remembering to switch over to Finder, pressing the correct key combination, or going through the menus, then selecting OK. It happens silently in the background, every Friday like clockwork. This is why we love computers.

For those who want the code:

tell application "Finder"
    set warns before emptying of trash to false
    empty trash
    set warns before emptying of trash to true
end tell

Empty Trash using Keyboard Maestro

If you’ve come as an elf, see it through as an elf.
Author Signature for Posts
0