- strFolder = "d:\aaa"
- Set objFSO = CreateObject("Scripting.FileSystemObject")
- Set colFiles = objFSO.GetFolder(strFolder).Files
- For each file in colFiles
- strfilename = file.Name
- If objFSO.GetExtensionName(strfilename) = Lcase("txt") Then
- If file.size = 0 Then
- WSH.Echo file & "是空文件,删除空文件重来!"
- EXIT For
- End If
- Set objTextStream = objFSO.OpenTextFile(file, 1, -2)
- strString = objTextStream.ReadAll
- strString = replace(strString, "【嘎嘎】", "【哈哈】")
- strString = replace(strString, "【拉拉】", "【嘻嘻】")
- strString = replace(strString, "【123456】", "【654321】")
- objTextStream.Close
- Set objTextFile = objFSO.OpenTextFile(file, 2, -2)
- objTextFile.Write strString
- End If
- Next
复制代码
|