Set objFS = CreateObject(\"Scripting.FileSystemObject\")
I was able to run your vbs file. The output did not come to the screen but the vbs did change the names of the original file names.
The original file rxc4.txt with text [ nooutput rxc45678 is here]
was changed to utput.txt and not to 45678.txt. This is clearly a flaw with the vbs solution
The ops specs were not followed. Please correct
C:\\test>type ghost831.vbs
Set objFS = CreateObject(\"Scripting.FileSystemObject\")
strFolder=\"c:\\test\"
Set objFolder = objFS.GetFolder(strFolder)
For Each strFile In objFolder.Files
If objFS.GetExtensionName(strFile) = \"txt\" Then
strFileName = strFile.Name
Set objFile = objFS.OpenTextFile(strFileName)
Do Until objFile.AtEndOfStream
strLine=objFile.ReadLine
If InStr(strLine,\"rxc\" ) > 0 Then
number=Mid(strLine,4,5) \'Get 5 characters afterwards
objFile.Close
strFile.Name = Trim(number)&\".txt\"
Exit Do
End If
Loop
End If
Next
Input:
C:test>findstr rxc *.txt
rxc1.txt:rxc12345
rxc2.txt:rxc23456
rxc3.txt:rxc34567
rxc4.txt:nooutput rxc45678 is here
Output:
C:\\test>dir * | sort
09/01/2010 04:55 AM 11 12345.txt
09/01/2010 04:55 AM 11 23456.txt
09/01/2010 04:55 AM 11 34567.txt
09/01/2010 04:55 AM 29 utput.txt
09/01/2010 04:55 AM 101 1.txt.txt
C:test>type 12345.txt
rxc12345
C:test>type utput.txt
nooutput rxc45678 is here
C:test>type 1.txt.txt
rxc1.txt:rxc12345
rxc2.txt:rxc23456
rxc3.txt:rxc34567
rxc4.txt:nooutput rxc45678 is here