Set objFSO = CreateObject("Scripting.FileSystemObject")
'*********************************************************
'Change "C:\TESTIT.TXT" to where you want the file to save
Set f1 = objFSO.OpenTextFile("C:\TESTIT.TXT", 8, True)
'*********************************************************
'*********************************************************
'Change "C:\VBFiles" to the folder you want to recurse through
objStartFolder = "C:\TESTIT"
'*********************************************************
Set objFolder = objFSO.GetFolder(objStartFolder)
Set colFiles = objFolder.Files
For Each objFile In colFiles
Set f2 = objFSO.OpenTextFile(objFolder.Path & "\" & objFile.Name, 1)
FirstLine = f2.ReadLine
If FirstLine = "TEST!" Then f1.WriteLine FirstLine
f2.Close
Next
ShowSubFolders objFSO.GetFolder(objStartFolder)
f1.Close
Set f1 = Nothing
Set f2 = Nothing
Set objFSO = Nothing
MsgBox "Complete!", vbInformation
Sub ShowSubFolders(Folder)
For Each Subfolder In Folder.SubFolders
Set objFolder = objFSO.GetFolder(Subfolder.Path)
Set colFiles = objFolder.Files
For Each objFile In colFiles
Set f2 = objFSO.OpenTextFile(Subfolder.Path & "\" & objFile.Name, 1)
FirstLine = f2.ReadLine
If FirstLine = "TEST!" Then f1.WriteLine FirstLine
f2.Close
f1.WriteLine Subfolder.Path & "\" & objFile.Name
Next
ShowSubFolders Subfolder
Next
End Sub