Help! "missing value" error....

Hi board,
i have a script which scans for specific folders and compares the modifivation date of the entire content.
If all of the content is older than a specific lifetime it gets deleted.

The script works fine on smaller folders hirachies, but on our backup system
it crashes after a while with “missing value” failure.
The failure happens randomly when the script tries to put the
modification dates into a list.

…set myfiles to modification date of entire contents of thefolder…
result {missing value,…}

The script checks folder on our server over the network.
Something to do with a time out / delay?!
Any help appreciated!
Thanks in advance,
Pat

guess I found the mistake…

by using the statement

set x to modification date of the entire contents of thefolder

i receive a list with randomly entries {missing value}

So I came up with something like this:

set x to entire contents of thefolder
repeat with myitem in x
set mydate to modification date of myitem
if mydate = missing value then
set mydate to modification date of myitem
else
set myitem to mydate
end if
end repeat

Now I recive a proper list with the modification dates.
Again the failure happens only on large folders over the network,
but that fixes it

Later,
pat

There’s a significant speed-up you can apply to your script by changing the logic.

In your current script, you get ‘entire contents of’ the folder.

You then walk through every item getting its modification date.

At the end, I assume since it’s not posted here, you then compare the dates to the required date (“…older than a specific lifetime”) and then decide whether or not to delete the folder.

You can speed this up significantly by walking the folder yourself, and stopping on the first file that doesn’t meet the lifetime criteria.

For example, if the first file in the folder was modified yesterday you don’t need to check any other file since you already know you can’t delete the folder, so your script finishes after the first file in a fraction of a second.

set OK2Delete to true -- assume it's OK
set cutoffDate to (current date) - (30 * days) -- 30 day cutoff
repeat with eachFile in (files of thefolder)
   if modification date of eachFile is greater than cutoffDate then
      -- file is newer, so exit out
      set OK2Delete to false
      exit repeat
   end if
end repeat

-- when you get here you've either checked every file and they're all older than cutoff date, or you found a newer file, so:
if OK2Delete is true then
   delete thefolder
end if

Thanks for your reply and suggestion.
My script has an exit repeat in it to leave the repeat
as soon as it finds a file which is younger than X.

It was just really annoying to receive this “missing value”
since it worked allright on my test database.
But browsing through the board I found that it is
know problem. Are there any other workarounds…?

By the way… :?:
it is not possible to come up with something like
set x to entire contents of the folder whose modification date is greater than current date + x days (That is not AS :smiley: )

Later,
pat