Deleting dated folders older than 30 days

Hello:

I am looking for some advice on how to delete dated folders older than 30 days. I created an applescript to archive files daily by placing them in daily dated folders inside another “backup” folder. Now, I am looking to have those folders deleted 30 days from creation:

Here is my current script that works on one folder “Test”, but the problem is the name of every folder will change when I put this into production based on my above criteria:

tell application “Finder”
activate
set filedata to info for folder “Test” as alias
set aMonthAgo to the (current date) - 30 * days
if creation date of folder “Test” comes before aMonthAgo then
delete folder “Test”
end if
end tell

Any help is appreciated. Thank you!

Hi,

this deletes every folder in the chosen folder with creation date older than 30 days.
Of course you can “hard code” the variable backupFolder (must be of class alias)

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

Fan-freaking-tastic. Thank you for the assistance.