Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help, I could use an extra set of eyes...

Status
Not open for further replies.

Gaffi1

Technical User
Apr 23, 2004
70
0
0
US
I'm trying to run a script that checks various log files with filenames in them to see if they exist or not and then writes results to a log file. So, I've used the fso.opentextfile to first open up a report of each of the log files in the main directory, then fso.opentextfile again to open up each individual log file to check and see if the files exists.

Checking a single log at a time with seperate scripts works perfectly. However, trying to automate this so that it switches between all the logs and keeps running gives me the following error:

Windows Script Host
Script: C:\Documents and Settings\desktop\testfilesearch-update.vbs
Line: 14
Char: 1
Error: File not found
Code: 800A0035
Source: Microsoft VBScript runtime error

I checked and made sure that everything exists, and it does, but I'll be darned if I can figure out why it errors out. Please help, my eyes hurt, lol.

Code:
Dim fso, logFileName, logFile, f, Msg, startFolder, lookingfor, count, l, reqlogs

logFileName = "C:\Documents and Settings\Desktop\J3715168r_0604251600" & ".out"
Set fso = CreateObject("Scripting.FileSystemObject")
Set logFile = fso.CreateTextFile(logFileName, True)

Const ForReading = 1, ForWriting = 2, ForAppending = 8

Set l = fso.OpenTextFile("C:\soundservant\ftp\currentreqfiles.log", ForReading)

	Do Until l.atendofstream = True
		reqlogs = l.Readline

Set f = fso.OpenTextFile(reqlogs, ForReading)
	Do While f.atendofstream <> True
		ReadTextFileText = f.Readline
		filename = right(readtextfiletext,49)
		lookingfor = filename
		fullid = left(readtextfiletext,16)
		studyid = left(readtextfiletext,3)
		qidprep = left(fullid,6)	
		questionid = right(qidprep,3)
		sampleid = right(fullid,10)
	startFolder = "C:\Documents and Settings\Desktop"
	Count = 0
	SearchForFiles startFolder, lookingfor, logFile
	wscript.echo lookingfor
		if count = 0 then
			logfile.WriteLine studyid & " " & questionid & " " & sampleid & " " & filename & " " & "-1"
		End If
	Loop
Loop

Sub SearchForFiles(folderName, lookingfor, fileObject)
    Dim folder, file, fileCollection, folderCollection, subFolder
    Set folder = fso.GetFolder(folderName)
    Set fileCollection = folder.Files
    For Each file In fileCollection
        If file.name = lookingfor Then
		count = 1
            fileObject.WriteLine studyid & " " & questionid & " " & sampleid & " " & file.name & " " & file.size
		Else
			count = count + 0
        End If
    Next

    Set folderCollection = folder.SubFolders
    For Each subFolder In folderCollection
       SearchForFiles subFolder.Path, lookingfor, logFile
    Next
End Sub
 
nevermind, figured it out.... I was reading into the reqlog just the file name, not the path. I'm not sure how it was able to find the first files information, but either way, once I added full pathnames it worked brilliantly.
 
Are the pathnames in currentreqfiles.log absolute or relative ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top