I am getting this error:
"C:\se2.vbs(28, 6) Microsoft VBScript runtime error: Input past end of file"
when I run my script (I italicized LINE 28):
Dim strInput
Dim filesys
Dim path
Set filesys=CreateObject("Scripting.FileSystemObject")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set oFSO = CreateObject("Scripting.FileSystemObject")
objStartFolder = "C:\Program Files\Apache Software Foundation\Tomcat 7.0_Tomcat7_1010\webapps\Geniisys\" 'Directory to search
objTempFolder = "C:\Users\njediaz\Desktop\temp\"
objOutputFile = "C:\Users\njediaz\Desktop\output\files.txt"
strInput = InputBox("Enter file to search (case sensitive):")
strSearchFor = strInput
ShowSubfolders objFSO.GetFolder(objStartFolder)
Sub ShowSubFolders(Folder)
'Wscript.Echo Folder.Path
For Each objFile in Folder.files
' Wscript.Echo Folder.Path & "\" & objFile.Name
path = Folder.Path & "\" & objFile.Name
If InStr(oFSO.OpenTextFile(path).ReadAll, strSearchFor) > 0 Then
filesys.CopyFile path , objTempFolder & objFile.Name
Else
WScript.Sleep (100)
END If
Next
For Each Subfolder in Folder.SubFolders
ShowSubFolders Subfolder
Next
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Script to log common files
Set fs = CreateObject("Scripting.FileSystemObject")
'Log file name
Set logFile = fs.OpenTextFile(objOutputFile, 2, True)
'Directory you want listed
Set folder = fs.GetFolder(objTempFolder)
Set files = folder.Files
For Each file in files
logFile.writeline(file.name)
Next
logFile.close
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'Script to delete
Const DeleteReadOnly = TRUE
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.DeleteFile(objTempFolder & "*"), DeleteReadOnly
MsgBox "Done."
Help please! Thanks!
I found out the problem. The error occurred when the script searched for a string in a BLANK TEXT FILE. I tried adding this:
Looks like one of the files has zero size. Evidence:
output: