Torgeir
Wed May 26 11:32:03 CDT 2004
Doug Schumann wrote:
> Try this -
>
> dtCheck = Dateadd("d",-2,date)
>
> set objFileSys = createobject
> ("scripting.filesystemobject")
> set objFolder = objfilesys.GetFolder
> ("c:\SomeFolder\OtherFolder\")
>
> doFolder objFolder
>
> sub doFolder(myFolder)
> set objFiles = myFolder.files
> for each objfile in objFiles
> if objfile.datelastmodified < dtcheck then
> objfile.delete
Hi
You should not do the file delete while you still are looping through
a file collection returned from the File System Object (FSO). The
collection may get mixed up. Create an array of the file objects to
avoid this. See my other post in his thread for an example...
--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/community/scriptcenter/default.mspx