Sorry I haven't gotten to this sooner. I have some code that just demonstrates the name replacement since I think that is the biggest hurdle right now. I also don't have it writing out to a file, I'm just using echos to show what it is doing. I just wanted to present the logic and you can work it into your script however you see fit.
First, I have a file named Data-OldHostnamesToNew.txt. It contains this:
NAME-55-2950-SWT1,NAME55-SWT1
NAME53-2550-SAL1,NAME53-SAL1
Next I have a file named Data-EditedShIntDesc.txt. It contains this:
Gi1/1 description NAME-55-2950-SWT1(Gi0/1)(MGMT)
Gi1/21 description DAC-NAME53-MTRO-SWT6(SFP-C)::NAME53-2550-SAL1(6.1)
Gi1/43.1040 description SOME-HIGH-SCHOOL:249-001i
Then I have this script:
Option Explicit
Dim oFSO : Set oFSO = CreateObject("Scripting.FileSystemObject")
Dim dicReplacements : Set dicReplacements = CreateObject("Scripting.Dictionary")
Dim arrLines : arrLines = Split(oFSO.OpenTextFile("C:\Temp\Data-OldHostnamesToNew.txt").ReadAll(), vbCrLf)
Dim strLine
Dim strOldName
Dim strNewLine
For Each strLine in arrLines
if strLine <> "" Then
dicReplacements.Add Split(strLine, ",")(0), Split(strLine, ",")(1)
End If
Next
For Each strOldName in dicReplacements.Keys()
WScript.Echo "OLD NAME = " & strOldName & vbTab & "MATCHING NEW NAME = " & dicReplacements(strOldName)
Next
WScript.Echo ""
WScript.Echo "**************"
WScript.Echo ""
arrLines = Split(oFSO.OpenTextFile("C:\Temp\Data-EditedShIntDesc.txt").ReadAll(), vbCrLf)
For Each strLine In arrLines
WScript.Echo "CHECKING: " & strLine
For Each strOldName in dicReplacements.Keys()
If InStr(strLine, strOldName) > 0 Then
WScript.Echo vbTab & "I found " & strOldName & " in this line. Replacing it now"
strNewLine = Replace(strLine, strOldName, dicReplacements(strOldName))
WScript.Echo vbTab & "NEW LINE: " & strNewLine
Exit For
End If
Next
Next
The output from this script is:
OLD NAME = NAME-55-2950-SWT1 MATCHING NEW NAME = NAME55-SWT1
OLD NAME = NAME53-2550-SAL1 MATCHING NEW NAME = NAME53-SAL1
**************
CHECKING: Gi1/1 description NAME-55-2950-SWT1(Gi0/1)(MGMT)
I found NAME-55-2950-SWT1 in this line. Replacing it now
NEW LINE: Gi1/1 description NAME55-SWT1(Gi0/1)(MGMT)
CHECKING: Gi1/21 description DAC-NAME53-MTRO-SWT6(SFP-C)::NAME53-2550-SAL1(6.1)
I found NAME53-2550-SAL1 in this line. Replacing it now
NEW LINE: Gi1/21 description DAC-NAME53-MTRO-SWT6(SFP-C)::NAME53-SAL1 (6.1)
CHECKING: Gi1/43.1040 description SOME-HIGH-SCHOOL:249-001i
CHECKING:
CHECKING: