Continue reading to learn how to create this AppleScript.
Creating the AppleScript
Open Script Editor.app (it can be found in /Applications/AppleScript). When you have the application opened, type (or copy / paste) the entire AppleScript below.
set backupFolder to (choose folder)
tell application "Finder" to set theseFolders to (get folders of backupFolder)
repeat with oneFolder in theseFolders
if (creation date of (info for oneFolder as alias) < (current date) - 30 * days) then
tell application "Finder" to delete oneFolder
end if
end repeat
When you are finished, your script should look similar to the one below.

You can save this script as an application by clicking File > Save As, and choosing "Application" from the "File Format" drop-down box. Type a name and location for your script to be saved and then click the "Save" button.

To run this script, you can double-click on the application that you just created or you can drag it into the dock for easy clicking. When you run the script, you will be presented with a dialog asking you for a folder. Browse to the parent (top-level) folder that contains folders you would like to be searched by date. The script will then find the folders that are older than 30 days and move them to the Mac OS X trash bin.
Additional notes
- Before you remove the files from the trash bin, make sure they are the files you wanted to delete.
- This script only removes folders, so be sure to organize your files within the folders accordingly.
- Be cautious when using this script, as it moves files. TUAW is not responsible for data loss due to incorrect usage of this script.











Reader Comments (Page 1 of 1)
5-05-2008 @ 11:55AM
Picazsoo said...
Wouldn`t it be safer to just label those folders with a certain colour and later search in Finder for all folders with this label and delete them from there? It is much safer than just moving them straight to trash...
Just my 2 cents...
Reply
5-05-2008 @ 12:32PM
Bob said...
find /path/to/directory -type d -mtime +30 -exec rm -r {} \;
Reply
5-05-2008 @ 2:40PM
Jachym Metlicka said...
Thanks. That's much easier (-:
5-05-2008 @ 1:08PM
Murphy Mac said...
Some day I'd like to see a how-to post somewhere, anywhere, without any comments that say, "Wouldn't it be easier to just..."
Go ahead, suggest ANOTHER way. The more ways the better. But to suggest your way is the best way and every other way is inferior is arrogant. Take a look around. Just, just just just just just. "Why not just....?" "Couldn't you just.....?" So annoying.
Look - JUST write your other method without slamming the way someone JUST took the time to write up. Leave the JUST out.
Reply
5-05-2008 @ 2:34PM
Timmargh said...
Well said Murphy. Well said.
5-05-2008 @ 2:33PM
Picazsoo said...
I am sorry if my comment did sound like that. I am not from an english speaking country so these nuances in language aren't as easy to understand as you might think.
On the other side, I didn't want to be offensive in any way, but you surely wanted to. Actually the reason I posted what I posted was because I hoped someone would suggest the way to do what I wanted. I use Hazel to do this kind of stuff.
Sincerely, Jachym Metlicka
5-05-2008 @ 2:59PM
Murphy Mac said...
Picazsoo - I'll be the first to admit I often forget how many posters don't speak English as their first language. And I'm duly impressed that they can master technology in anything other than their native language.
But the "just" thing pervades every single posting about how to do something. And people who DO speak English as their first language use the phrasing over and over again. I don't know if they realize it's offensive or not. But it is. Simply adding the word "just" devalues the content of the post, if people realize it or not.
I apologize for offending you. I don't know why I ever mention the JUST thing, it's one of those things I need to learn to ignore if I'm going to participate in sites like this.
Reply
5-05-2008 @ 3:25PM
Picazsoo said...
I'll definitely try to avoid this evil "just" from now on (-:
About the tech stuff: Almost all technology I use is in english language. I went to Texas last year as an exchange student, but there are some things one will never learn unless one's a real native speaker.
I'm glad we figured this out.
End of Transmission
5-05-2008 @ 3:39PM
Mason said...
And how would the script look for empty folders?
Reply
5-06-2008 @ 12:25PM
Ian said...
Why not just highlight them all and hit command-delete?
Reply