folder problems...

Hi, Yes I am a newbie. I have tried dozens and dozens of permutations to do a simple task. I get the same error each time.
What I want to do is empty the contents of a folder within the Preferences folder in my Sys Folder. But I only want it to delete the files that are more than 10 hrs old.
And I will be placing the finished app in my startup items. The first thing it will do is check to see if it is Friday, since this is the day I want it to do the clean up. This part I have figured out already.
But when it gets to the line that tells it to delete all items in that particular folder it keeps saying that it CAN’T GET every item in that folder. It doesn’t work with or without the part of the code to check if the files are over 10 hours old. Any help would be appreciated here.
Thanks

: Hi, Yes I am a newbie. I have tried dozens and dozens of
: permutations to do a simple task. I get the same error each
: time.

: What I want to do is empty the contents of a folder within the
: Preferences folder in my Sys Folder. But I only want it to
: delete the files that are more than 10 hrs old.

: And I will be placing the finished app in my startup items. The
: first thing it will do is check to see if it is Friday, since
: this is the day I want it to do the clean up. This part I have
: figured out already.

: But when it gets to the line that tells it to delete all items in
: that particular folder it keeps saying that it CAN’T GET every
: item in that folder. It doesn’t work with or without the part
: of the code to check if the files are over 10 hours old. Any
: help would be appreciated here.

Without seeing your code it’s impossible to know what your problem is. My first guess would be that you’re asking for the contents of a folder outside of a Finder tell block.

I’d do it this way:

property theFldr : choose folder with prompt "Select the target folder:"

set thisDate to (current date)
if date string of thisDate does not contain "Friday" then return
set cutOff to thisDate - (10 * hours)
tell application "Finder"
        try
                set fileList to files of theFldr as alias list
        on error
                set fileList to files of theFldr as alias as list
        end try
end tell
set delList to {}
repeat with aFile in fileList
        set theInfo to info for aFile
        if modification date of theInfo < cutOff then
                set end of delList to aFile
        end if
end repeat
tell application "Finder" to delete delList

Marc K. Myers
Marc@AppleScriptsToGo.com>
AppleScriptsToGo
4020 W.220th St.
Fairview Park, OH 44126
(440) 331-1074

[02/23/2002 2:48:19 AM]