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 20:07:26 -0500
It looks like that's due to the line wrapping in e-mails. That entire
quoted text should be on one line, but it was too long and so the
e-mail software split it into two lines. I have fixed it so that the
code works by using the "," symbol to manually split the line. Here's
the fixed code.
- 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 4:01 PM, Mike Flowers wrote:
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.
_______________________________________________
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.