Play PC games on your Mac? TUAW tests CrossOver

AppleScript: Delete old folders

If you work like I do, then you have a hierarchy of folders contained in a single folder that allows you to manage project files, notes, etc. Well, when it comes time to chunk those old files, normally you have to manually go through and remove them; this task can become daunting if you have multiple project folders. I am going to show you an easier way. In this how-to, we'll cover how to create an AppleScript that will allow you to remove folders that are older than 30 days.

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.

Saving the script
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.

Running the script
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.

Related Headlines

Reader Comments (Page 1 of 1)

Add your comments

Please keep your comments relevant to this blog entry. Email addresses are never displayed, but they are required to confirm your comments.

When you enter your name and email address, you'll be sent a link to confirm your comment, and a password. To leave another comment, just use that password.

To create a live link, simply type the URL (including http://) or email address and we will make it a live link for you. You can put up to 3 URLs in your comments. Line breaks and paragraphs are automatically converted — no need to use <p> or <br> tags.

New Users

Current Users

TUAW Features

Mac 101 iPhone Around the Worldask-tuaw
Mac News
Macworld (497)
.Mac (38)
Accessories (624)
Airport (75)
Analysis / Opinion (1295)
Apple (1612)
Apple Corporate (547)
Apple Financial (186)
Apple History (39)
Apple Professional (49)
Apple TV (160)
Audio (441)
Bad Apple (119)
Beta Beat (149)
Blogging (87)
Bluetooth (15)
Bugs/Recalls (56)
Cult of Mac (870)
Deals (201)
Desktops (115)
Developer (206)
Education (93)
eMac (10)
Enterprise (127)
Features (375)
Freeware (363)
Gaming (344)
Graphic Design (18)
Hardware (1272)
Holidays (41)
Humor (590)
iBook (65)
iLife (237)
iMac (183)
Internet (306)
Internet Tools (1289)
iPhone (1356)
iPod Family (2021)
iTS (962)
iTunes (795)
iWork (18)
Leopard (356)
Mac mini (109)
Mac Pro (50)
MacBook (197)
MacBook Air (77)
Macbook Pro (215)
Multimedia (434)
Odds and ends (1420)
Open Source (272)
OS (891)
Peripherals (190)
Podcasting (181)
Podcasts (83)
Portables (197)
PowerBook (138)
PowerMac G5 (50)
Retail (573)
Retro Mac (47)
Rig of the Week (42)
Rumors (613)
Software (4223)
Software Update (395)
Steve Jobs (252)
Stocking Stuffers (55)
Surveys and Polls (97)
Switchers (111)
The Woz (34)
TUAW Business (227)
Universal Binary (281)
UNIX / BSD (62)
Video (910)
Weekend Review (74)
WIN Business (49)
Wireless (80)
XServe (35)
Mac Events
One More Thing (27)
Liveblog (0)
Other Events (231)
WWDC (182)
Mac Learning
Ask TUAW (96)
Blogs (85)
Books (23)
Books and Blogs (63)
Cool tools (444)
Hacks (463)
How-tos (480)
Interviews (33)
Mods (184)
Productivity (583)
Reviews (99)
Security (145)
Terminal Tips (56)
Tips and tricks (560)
Troubleshooting (161)
TUAW Features
iPhone 101 (23)
TUAW Labs (3)
Blast From the Past (17)
TUAW Tips (141)
Flickr Find (33)
Found Footage (70)
Mac 101 (81)
TUAW Interview (31)
Widget Watch (196)
The Daily Best (2)
TUAW Faceoff (6)

RESOURCES

RSS NEWSFEEDS

Powered by Blogsmith

Sponsored Links

The Unofficial Apple Weblog (TUAW) bloggers (30 days)

#BloggerPostsCmts
1Dave Caolo510
2Cory Bohon434
3Mat Lu374
4Erica Sadun351
5Scott McNulty352
6Michael Rose2718
7Brett Terpstra220
8Mike Schramm204
9Steven Sande169
10Robert Palmer1524
11Joshua Ellis74
12Christina Warren619
13Nik Fletcher41
14Chris Ullrich31
15Jason Clarke11
16Lisa Hoover11
17Victor Agreda, Jr.14

Featured Galleries

Macworld 2008 Keynote
Macworld 2008 Build-up
Macworld Expo 2007 show floor
The Macworld Faithful in Line
iPhone First Look
iPhone 2.0 - .Mac push e-mail
iMac 1998
TUAW Faceoff: Screenshot apps on the firing line
Boston Apple Store (Boylston Street)

 

    Most Commented On (7 days)

    Recent Comments

    More Apple Analysis

    More from AOL Money and Finance

    Weblogs, Inc. Network

    Other Weblogs Inc. Network blogs you might be interested in: