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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I'm lost - I need a script to cycle through a directory - parse files

Status
Not open for further replies.

tcspine

IS-IT--Management
Jan 2, 2008
31
US
In detail, I need to parse 'msinfo32' files that have been converted to text and pull from them 'computer name' and 'system model'.

The files I need to parse are named after the user (first initial, middle initial, last name).

I don't want to have to input the file name to do this, and I need it to go through the whole directory without having to have the filename hard coded.

 
Have you tried something like this:

Dim objFSO, objFile
Set objFSO = CreateObject ("Scripting.FileSystemObject")

For Each objFile In objFSO.GetFolder ("C:\DataFolderName").Files ' or wherever your data Is
ParseFile objFile.Path
Next

Sub ParseFile (ByVal strFile)

Dim objInFile
Dim strLineIn

Set objInFile = objFSO.OpenTextFile (strFile, 1)

' Read the file line by line
Do While Not objInFile.AtEndOfStream
strLineIn = objFile.ReadLine
' insert code to do whatever you want to
' do with the data contained in strLineIn
Loop

objInFile.Close
Set objInFile = Nothing

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top