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
- Daily App: MyScript Calculator solves your hand-written math equations
- Findery app lets you discover the world around you using annotated notes and maps
- The Learnist app brings its crowd-sourced collection of information to your iPhone
- My cat Cinnamon reviews Friskies Cat Fishing 2
- Photo Grid Collage Maker is capable and free
- iExit gets new features and is now free