One of the services we offer is data backups and recovery on machines checked into service. Customer data is backed up to our servers in a variety of ways, depending on the state of the hard drive and if necessary, restored to customer machines before pickup time. After a few days to allow for customers to confirm the data, the backups are deleted from our server.

We sometimes experience permission-related conflicts when attempting to remove those old backups from our server. Data retrieved from failing hard drives can have corrupted permissions and cannot be removed by simply emptying the trash as usual. Normally I would use the “sudo rm -rf” command in terminal, and drag in the corrupted files/folders into the terminal window for deletion.

I wanted to speed this process up a bit, as I was doing a lot of data backups in this way, and it was proving to be slightly more time consuming than it needed to be. I knew Automator would be able to help me out, so I decided to create a very simple workflow that would allow me to simply double-click to execute the necessary command.

I opened up Automator, and selected New > Application. On the sidebar, I selected Utilities, and dragged “Run Shell Script” onto the workspace on the right. The command I then inputted is “sudo rm -rf ~/.Trash/*”. This command, when executed, is simply telling your computer to empty whatever’s in the trash, whilst bypassing any permissions tied to those files. The last step is to save the workflow as an application to the desired location on your computer. I also swapped in the stock Apple Trash icon for quick visual identification.