Re: delete files in nested folders
Re: delete files in nested folders
- Subject: Re: delete files in nested folders
- From: Graff <email@hidden>
- Date: Tue, 18 Nov 2003 14:29:58 -0500
This code seems to work fine and doesn't delete files that are
invisible in the Finder, including files that start with a dot like
".DS_Store".
- Ken
code:
--this runs if the icon is double-clicked
on run
set theFolder to choose folder with prompt ,
"Choose a folder with to clean of old files."
deleteOld(theFolder)
end run
--this runs if a file is dropped on the icon
on open openedfolder
set theFolder to openedfolder as alias
deleteOld(theFolder)
end open
-- here is the main function
on deleteOld(theFolder)
set folderList to {}
set purgeDate to (current date) - (4 * weeks)
copy theFolder to the end of folderList
repeat while length of folderList is greater than 0
tell application "Finder"
set currentFolder to the first item in folderList
set folderList to the rest of folderList
set deleteList to every file of currentFolder whose modification
date is less than purgeDate
repeat with currentItem in deleteList
delete currentItem
end repeat
set newFolders to every folder of currentFolder
set folderList to folderList & newFolders
end tell
end repeat
beep
display dialog "Done Cleaning" with icon note giving up after 2
end deleteOld
On Nov 18, 2003, at 11:10 AM, Mike Flowers wrote:
I am trying to make a script to delete files in nested folders 4 weeks
after its creation date. I have this so far:
...
But it tells me it cant get file .DS_Store. Can someone help me with
this? If anyone has a better way to do it, let me know.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.