'Here's my code with the configuration variables defined

Option Explicit

Dim strStartFolder, arrKeywords, strOutputFile, strKeywordFile
strStartFolder = "\\asstr-mirror\WWW\www.asstr-mirror.org\files\Collections\USENET" ' Target directory to scan
strOutputFile  = "\\asstr-mirror\WWW\www.asstr-mirror.org\files\Collections\USENET\DeleteSPAM.bat" ' Path to the log file
strKeywordFile = "\\asstr-mirror\WWW\www.asstr-mirror.org\files\Collections\USENET\DeleteSPAM-keywords.txt" ' Path to your keywords text file

Dim objFSO, objLogFile
Dim objFile, objSubFolder, strContent, strKey, objTS
Set objFSO = CreateObject("Scripting.FileSystemObject")

' Load keywords from the text file
arrKeywords = LoadKeywords(strKeywordFile, objFSO)

' Ensure keywords were loaded and the target folder exists
If IsArray(arrKeywords) Then
    If objFSO.FolderExists(strStartFolder) Then
        Set objLogFile = objFSO.OpenTextFile(strOutputFile, 2, True)
        
        ProcessFolder objFSO.GetFolder(strStartFolder)
        
        objLogFile.WriteLine "pause"
        objLogFile.Close
        WScript.Echo "Scan complete. Results saved to: " & strOutputFile
    Else
        WScript.Echo "Error: Target folder not found."
    End If
Else
    WScript.Echo "Error: Could not load keywords from file."
End If

' --- Subroutines and Functions ---

Sub ProcessFolder(objFolder)
    For Each objFile In objFolder.Files
        On Error Resume Next ' Skip locked or unreadable files
        Set objTS = objFSO.OpenTextFile(objFile.Path, 1)
        
        If Err.Number = 0 And LCase(objFSO.GetExtensionName(objFile.Path)) = "txt" And objFile.Name <> "DeleteSPAM-keywords.txt" Then
            strContent = objTS.ReadAll
            objTS.Close
            
            strContent = Right(strContent, Len(strContent)-InStr(1, strContent, "===================", 1))
            For Each strKey In arrKeywords
                If InStr(1, strContent, strKey, 1) > 0 Then
                    objLogFile.WriteLine "del " & Chr(34) & objFile.Path & Chr(34)
                    WScript.Echo objFile.Path & "  -  " & strKey
                    Exit For
                End If
            Next
        End If
        Err.Clear
        On Error GoTo 0
    Next

    For Each objSubFolder In objFolder.SubFolders
        ProcessFolder objSubFolder
    Next
End Sub

Function LoadKeywords(strFilePath, objFileSystem)
    Dim objFileStream, strLine, arrTemp(), intCount
    intCount = 0
    
    If objFileSystem.FileExists(strFilePath) Then
        Set objFileStream = objFileSystem.OpenTextFile(strFilePath, 1)
        
        Do Until objFileStream.AtEndOfStream
            strLine = Trim(objFileStream.ReadLine)
            ' Only add the line if it is not empty
            If strLine <> "" Then
                ReDim Preserve arrTemp(intCount)
                arrTemp(intCount) = strLine
                intCount = intCount + 1
            End If
        Loop
        
        objFileStream.Close
        LoadKeywords = arrTemp
    Else
        WScript.Echo "Error: Keyword file not found at " & strFilePath
        LoadKeywords = False
    End If
End Function
