Re:delete files in nested folders
Re:delete files in nested folders
- Subject: Re:delete files in nested folders
- From: Mike Flowers <email@hidden>
- Date: Tue, 18 Nov 2003 16:01:08 -0500
It gives me an error "can't make some data into expected type" when it gets to:
"set deleteList to every file of currentFolder whose modification
date is less than purgeDate"
what's it expecting?
------
On Nov 18, 2003, at 11:10 AM, Ken wrote:
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
_______________________________________________
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.