This is what I have done so far. I need to be able to check to see if all of the files exists. The file names will come from a list in a text file. Currently I get a mismatch error when the code executes at the IF/THEN statements
CODE
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject"
Set objOpen = objFSO.OpenTextFile("C:\AIX36009_Req.txt", ForReading)
Dim arrFileName()
i = 0
Do While objOpen.AtEndOfStream <> true
text = objOpen.ReadLine
'WSCript.Echo text
ReDim Preserve arrFileName(i)
arrFileName(i) = text
i=i+1
loop
objOpen.Close
Set objOpen = Nothing
'WSCript.Echo arrFilename(0)
'text = "objFSO.FileExists(" & arrFilename(0) & "
"
'WSCript.Echo text
For i=0 to UBound(arrFileName)
'WScript.Echo arrFileName(i)
strNextDocument = "(objFSO.FileExists(""" & arrFilename(i) & """
)"
strFullStatement = strNextDocument & " " & "AND" & " " & strFullStatement
Next
'WScript.Echo Left(strFullStatement,len(strFullStatement) - 5) 'removes the last AND from the strFullStatement string
strFileExistsStatement = Left(strFullStatement,len(strFullStatement) - 5) 'removes the last AND from the strFullStatement string
WScript.Echo strFileExistsStatement
str1 = (objFSO.FileExists("AIX36009P01.doc"
) AND (objFSO.FileExists("AIX36009.doc"
)
If strFileExistsStatement then
WScript.echo "Files Exists"
Else
WScript.echo "Files dose not Exists"
End If
/CODE
CODE
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject"
Set objOpen = objFSO.OpenTextFile("C:\AIX36009_Req.txt", ForReading)
Dim arrFileName()
i = 0
Do While objOpen.AtEndOfStream <> true
text = objOpen.ReadLine
'WSCript.Echo text
ReDim Preserve arrFileName(i)
arrFileName(i) = text
i=i+1
loop
objOpen.Close
Set objOpen = Nothing
'WSCript.Echo arrFilename(0)
'text = "objFSO.FileExists(" & arrFilename(0) & "
'WSCript.Echo text
For i=0 to UBound(arrFileName)
'WScript.Echo arrFileName(i)
strNextDocument = "(objFSO.FileExists(""" & arrFilename(i) & """
strFullStatement = strNextDocument & " " & "AND" & " " & strFullStatement
Next
'WScript.Echo Left(strFullStatement,len(strFullStatement) - 5) 'removes the last AND from the strFullStatement string
strFileExistsStatement = Left(strFullStatement,len(strFullStatement) - 5) 'removes the last AND from the strFullStatement string
WScript.Echo strFileExistsStatement
str1 = (objFSO.FileExists("AIX36009P01.doc"
If strFileExistsStatement then
WScript.echo "Files Exists"
Else
WScript.echo "Files dose not Exists"
End If
/CODE