| |
tinyang
Posts: 3
Score: 0
Joined: 6/7/2002
From: USA
Status: offline
|
Hello All! I have run into some difficulty getting a file collection to be recognized as a collection in a script. In my logfile, I keep getting a "An error occured while processing. 451, Object not a collection. Stopped on error. 451, Object not a collection" error, but I don't understand why. See procedure code below. This one is really eating me up! I'm kinda new at scripting. I already have posted on a few forums, and noone seems to see what's causing the problem. Any input would be greatly appreciated. Set objFS = WScript.CreateObject("Scripting.FileSystemObject") Set objFolder = objFS.GetFolder(strDestOrig) ' Set pointer to files in the folder Set objFiles = objFolder.Files On error resume next For each objFile in objFiles 'this is where I get the error. nTotalFile = nTotalFile + 1 strOldFile = mid(objFile.Path, len(strSrcOrig) + 1) strNewFile = strDestOrig & strOldFile If objFS.FileExists(strNewFile) Then ' File exists on target. Check dates Set objDestFile = objFS.GetFile(strNewFile) If objFile.DateLastModified > objDestFile.DateLastModified Then ' Source is newer nFilesCopied = nFilesCopied + 1 ' Turn off Readonly attr If objDestFile.Attributes and 1 Then objDestFile.Attributes = objDestFile.Attributes - 1 End if ' Turn of Hidden attr If objDestFile.Attributes and 2 Then objDestFile.Attributes = objDestFile.Attributes - 2 End if ' Turn of System attr If objDestFile.Attributes and 4 Then objDestFile.Attributes = objDestFile.Attributes - 4 End if objLogFile.WriteLine("Updated -> " & objFile.Path & " " & objFile.DateLastModified) objFS.CopyFile objFile.Path, objDestFile.Path, True Else 'Destination is not older objLogFile.WriteLine("Skipped -> " & objFile.Path & " " & objFile.DateLastModified) End If Else 'Doesn't exist on target objLogFile.WriteLine("Added -> " & objFile.Path & " " & objFile.DateLastModified) nFilesCopied = nFilesCopied + 1 objFS.CopyFile objFile.Path, strNewFile, True End if ' Errors? If Err then objLogFile.WriteLine("Stopped on error. " & Err.number & Err.Description) objLogFile.Close Set objLogFile = Nothing End if Set objFS = Nothing End if Next
|
|