[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
本帖最后由 more 于 2012-2-9 23:04 编辑
  1. Option Explicit
  2. If WScript.Arguments.Count = 0 Then
  3. MsgBox "把要处理的文件拖到我身上就行了...", vbOKOnly, "友情提示..."
  4. WScript.Quit
  5. End If
  6. Dim strFile, objFso, objFile, objReg, ojbMtchs, objMtch, objFl, strRead, strSrc, strDst
  7. strSrc = "WITH"
  8. strDst = "Ab"
  9. strFile = WScript.Arguments(0)
  10. Set objFso = CreateObject("Scripting.FileSystemObject")
  11. With objFso
  12. Set objFile = .OpenTextFile(strFile, 1, False)
  13. Set objFl = .OpenTextFile(.GetSpecialFolder(2) & "\" & _
  14. .GetBaseName(strFile) & ".txt", 2, True)
  15. End With
  16. Set objReg = New RegExp
  17. With objReg
  18. .Global = True
  19. .IgnoreCase = False
  20. .Pattern = strSrc
  21. End With
  22. Do Until objFile.AtEndOfStream = True
  23. strRead = objFile.readline
  24. If objReg.Test(strRead) = True Then
  25. strRead = objReg.Replace(strRead, strDst)
  26. End If
  27. objFl.writeline strRead
  28. Loop
  29. objFile.close
  30. objFl.close
  31. With objFso
  32. .CopyFile .GetSpecialFolder(2) & "\" & .GetBaseName(strFile) & ".txt", strFile, True
  33. End With
  34. Set objReg = Nothing
  35. Set objFso = Nothing
  36. Set objFile = Nothing
  37. Set objFl = Nothing
  38. CreateObject("Wscript.Shell").Run "notepad " & strFile, 1
复制代码

TOP

返回列表