- Set fso = Createobject("Scripting.FileSystemObject")
- For Each file in fso.GetFolder(".").Files
- If LCase(Right(file, 4)) = ".inf" Then
- RegEx file, GetInfFormat(file)
- End If
- Next
-
- MsgBox "OK"
-
- Function GetInfFormat(ByVal file)
- With CreateObject("ADODB.Stream")
- .Mode = 3
- .Type = 1
- .Open
- .LoadFromFile file
- bin = .Read(2)
- End With
- s = Hex(AscB(MidB(bin, 1, 1))) & Hex(AscB(MidB(bin, 2)))
- If UCase(s) = "FEFF" or UCase(s) = "FFFE" Then
- GetInfFormat = -1
- Else GetInfFormat = 0
- End If
- End Function
-
- Sub RegEx(ByVal file, intFormat)
- Set f = fso.OpenTextFile(file, 1, false, intFormat)
- txt = f.ReadAll : f.Close
- Set re = New RegExp
- re.Pattern = "(\[Strings])([\s\S]+?)\1"
- re.IgnoreCase = true
- If Not re.Test(txt) Then Exit Sub
- Set f = fso.OpenTextFile("New_" & file.Name, 2, true, -1)
- f.Write re.Replace(txt, "$1$2") : f.Close
- End Sub
复制代码
|