Re:Delete Log files by date
Re:Delete Log files by date
- Subject: Re:Delete Log files by date
- From: Mike Flowers <email@hidden>
- Date: Fri, 16 Jan 2004 09:29:30 -0500
At 9:20 AM +0000 16/01/04, Buttery, Ian wrote:
>
Does anyone know of a script which will allow me to delete log files
>
from a folder which are more than 2 days old?
Maybe I can help you and get help for myself at the same time. This script works for me, but only if I have it use Choose Folder. If I put in a direct path like :Hard Drive:Scripts:, it returns an error saying "Can't find Hard Drive:Scripts.DS_Store. I look, and there is a .DS_Store file there. I would like to have this script so that it can run without my interaction.
I hope we both can get a solution.
Mike
set purgeDate to (current date) - (2 * days)
set fileRef to choose folder
tell application "Finder"
set bigList to list folder fileRef
set bigListpath to {}
repeat with eachItem in bigList
--try
set tempbiglistpath to fileRef & eachItem as string
set atempbiglistpath to tempbiglistpath as alias
set kindof to kind of atempbiglistpath
if kindof is "folder" then
set tempbiglistpath to tempbiglistpath & ":"
set littlelist to list folder tempbiglistpath
set littleListpath to {}
repeat with eachlitem in littlelist
set the littleListpath to tempbiglistpath & eachlitem
set alittleListpath to littleListpath as alias
set kindofl to kind of alittleListpath
set llmod to modification date of alittleListpath
set llinv to get info for alittleListpath
if llinv does not contain {visible:false} and kindofl is not "folder" and llmod < purgeDate then
delete file littleListpath
end if
end repeat
end if
if kindof is not "folder" then
set loosefile to tempbiglistpath as alias
set kindofloosefile to kind of loosefile
set loosefilemod to modification date of loosefile
set loosefileinfo to get info for loosefile
if loosefileinfo does not contain {visible:false} and kindofloosefile is not "folder" and loosefilemod < purgeDate then
delete file loosefile
end if
end if
--end try
end repeat
try
|empty|
end try
end tell
_______________________________________________
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.