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
- Vizzywig 8xHD price tag now a very affordable $49.99
- Automatic targets teen drivers with License+ service
- Dropbox adds support for TouchID
- YouTube for iOS gets updated with full support for iPhone 6 and 6 Plus
- iOS 8.0.1 update now available (Updated -- Don't update!)
- NFL Mobile updated for 2014 Season with new Fantasy Football features, NFL Now integration