4,008
社区成员
发帖
与我相关
我的任务
分享
Set WshShell = CreateObject("Wscript.Shell")
WshShell.Run "cmd /c dir /s/b *.cpt > list.txt",vbHide
Wscript.Sleep 1000
'WshShell.Charset = "UTF-8"
sFile = "list.txt"
Set objFSO = CreateObject("Scripting.FileSystemObject")
'objFSO.Charset = "UTF-8"
Set oFile = objFSO.OpenTextFile(sFile,1)
Do While Not oFile.AtEndOfStream
strLine = oFile.ReadLine
If Len(strLine) > 0 Then
Set File = objFSO.OpenTextFile(strLine, 1)
aryLines = File.ReadAll
File.Close
aryLines = Replace(aryLines, "ORCL_DS_MES", "SHLY_JIT_UAT")
Set File = objFSO.OpenTextFile(strLine, 2)
File.Write aryLines
File.Close
End If
Loop
oFile.Close
objFSO.DeleteFile sFile
Set objFSO = Nothing
Function LoadText(path, encoding)
With CreateObject("ADODB.Stream")
.Mode = 3
.Type = 1
.Open
.LoadFromFile path
.Position = 0
.Type = 2
.Charset = encoding
.Position = 0
LoadText = .ReadText(-1)
.Close
End With
End Function
Sub SaveAs(text, path, encoding)
With CreateObject("ADODB.Stream")
.Mode = 3
.Type = 2
.Open
.Charset = encoding
.WriteText text
.SaveToFile path, 2
.Close
End With
End Sub
Set WshShell = CreateObject("Wscript.Shell")
WshShell.Run "cmd /c dir /s/b *.cpt > list.txt",vbHide
Wscript.Sleep 1000
'WshShell.Charset = "UTF-8"
sFile = "list.txt"
Set objFSO = CreateObject("Scripting.FileSystemObject")
'objFSO.Charset = "UTF-8"
Set oFile = objFSO.OpenTextFile(sFile,1)
Do While Not oFile.AtEndOfStream
strLine = oFile.ReadLine
If Len(strLine) > 0 Then
aryLines = LoadText(strLine, "UTF-8")
aryLines = Replace(aryLines, "SHLY_JIT_UAT", "ORCL_DS_MES")
SaveAs aryLines, strLine, "UTF-8"
End If
Loop
oFile.Close
objFSO.DeleteFile sFile
Set objFSO = Nothing
Function LoadText(path, encoding)
With CreateObject("ADODB.Stream")
.Mode = 3
.Type = 1
.Open
.LoadFromFile path
.Position = 0
.Type = 2
.Charset = encoding
.Position = 0
LoadText = .ReadText(-1)
.Close ' 上边漏了 close
End With
End Function
Function LoadText(path, encoding)
With CreateObject("ADODB.Stream")
.Mode = 3
.Type = 1
.Open
.LoadFromFile path
.Position = 0
.Type = 2
.Charset = encoding
.Position = 0
LoadText = .ReadText(-1)
End With
End Function
Sub SaveAs(text, path, encoding)
With CreateObject("ADODB.Stream")
.Mode = 3
.Type = 2
.Open
.Charset = encoding
.WriteText text
.SaveToFile path, 2
.Close
End With
End Sub
Set WshShell = CreateObject("Wscript.Shell")
WshShell.Run "cmd /c dir /s/b *.cpt > list.txt",vbHide
Wscript.Sleep 1000
'WshShell.Charset = "UTF-8"
sFile = "list.txt"
Set objFSO = CreateObject("Scripting.FileSystemObject")
'objFSO.Charset = "UTF-8"
Set oFile = objFSO.OpenTextFile(sFile,1)
Do While Not oFile.AtEndOfStream
strLine = oFile.ReadLine
If Len(strLine) > 0 Then
aryLines = LoadText(strLine, "UTF-8")
aryLines = Replace(aryLines, "ORCL_DS_MES", "SHLY_JIT_UAT")
SaveAs aryLines, strLine, "UTF-8"
End If
Loop
oFile.Close
objFSO.DeleteFile sFile
Set objFSO = Nothing