Scan Computer for Specific Extension – Output to text file

email me

I created this while in a forensics computer course:

On error resume next

'SET VARIABLES
Dim objFSO, objTextStream
Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextStream = objFSO.OpenTextFile("Computer_Forensics.txt", ForWriting, True)

'SET STARTING PATH
Call RecursiveFolders("C:\")
objTextStream.Close()

'SUBROUTINE FOR CHECKING EXTENSIONS - TXT CAN BE CHANGED TO WHATEVER YOU'RE LOOKING FOR
Sub RecursiveFolders(strFolderPath)
Dim objFolder, objFile, objSubFolder
Set objFolder = objFSO.GetFolder(strFolderPath)

For Each objFile In objFolder.Files
If (InStr(objFile.Name, ".") > 0) Then
If (LCase(Mid(objFile.Name, InStrRev(objFile.Name, "."))) = ".txt") Then objTextStream.WriteLine(objfile.Path)
End If
Next

For Each objSubFolder In objFolder.SubFolders
Call RecursiveFolders(objSubFolder.Path)
Next
End Sub