AppleScript: Delete old folders
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
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.
- 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.
Subscribe to Newsletter
Software Updatesmore updates
- Daylite 5 adds refinements to the business management app
- 1Password 4.5 for iOS gains features, slims down
- IFTTT for iPad brings service/device mashups to your favorite tablet
- Daily App: Rormix brings indie music videos to your iPhone and iPad
- Pebble updates its iOS app with new apps, sharing options and v2.1 fix
- PSA: Pebble for iOS v.2.1 update contains critical flaw that breaks the app - Update