31 Days Of OS X Tips: Clean Up Your Files With Automator (Part 2)

On Friday, we showed you how to clear files out your Mac’s Downloads folder and back them up to another loacion. This time we’re going show you how to purge those Old Download archives on a monthly basis. This time we’re playing around with the Find command in bash. This is a helpful tool, but make sure you’re careful with the file paths here: Anything that meets the criteria you enter in will be deleted.

Before you continue, read yesterday’s tutorial to get caught up. This tutorial assumes you’re somewhat familiar with Automator and with the concept of the OS X command line (basically, that you know it exists).

  1. Open Automator, select Calendar Alarm from the new document picker, then click Choose.
  2. Click on Utilities in the left hand panel.
  3. Select Run Shell Script, then double-click it to add it to your workflow.
  4. In the panel that comes up put in the following code:

    #!/bin/bash
    thisUser="$(whoami)"
    find "/users/$thisUser/OldDownloads" -mtime +30 -delete
  5. Click File -> Save and name your event.
  6. Calendar will open and will create a new event at the current time. Edit the Calendar event and set the appropriate repeat frequency to once a month, and you’re all set.
Mac geek? Gamer? Why not both? Mike is a writer from Wisconsin who enjoys wasting immense amounts of time on the Internet. You can follow him on Twitter.