[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
本帖最后由 老刘1号 于 2017-10-29 19:15 编辑

回复 1# 33571918

无需任何第三方,存批即可
如果觉得可用,请支付到论坛支付宝账号
  1. OldStr="原来的字符串"
  2. NewStr="新的字符串"
  3. ' & @Echo off & Cls 2>Nul 3>nul
  4. ' & For /r "你的ZIP文件所在的路径" %%a in (*.ZIP) Do Echo "%%~fa" && Cscript -Nologo -E:Vbscript "%~0" "%%~fa"
  5. ' & Pause & Goto :EOF
  6. Rem Code BY 老刘
  7. Rem Zip,UnZip函数块感谢Demon、乱码
  8. Rem 其他均为原创
  9. Randomize
  10. YourZipFilePath=Wscript.Arguments(0)
  11. Dim fso
  12. Set fso = CreateObject("Scripting.FileSystemObject")
  13. TmpFolderName = Replace(Rnd,".","")
  14. fso.GetFolder(fso.GetSpecialFolder(2)&"\").SubFolders.Add TmpFolderName
  15. TmpFolderPath = fso.GetSpecialFolder(2)&"\"&TmpFolderName
  16. UnZip YourZipFilePath, TmpFolderPath
  17. ErgodicFolder TmpFolderPath,OldStr,NewStr
  18. Zip TmpFolderPath,YourZipFilePath
  19. Sub ErgodicFolder(Inputfolder,OldStr,NewStr)
  20. Dim objFolder,File,folder
  21. Dim fso
  22. Set fso = CreateObject("Scripting.FileSystemObject")
  23. Set objFolder=FSO.getFolder(Inputfolder)
  24. For Each File In objFolder.Files
  25. If UCase(FSO.GetExtensionName(File)) = "TXT" Then
  26. Str = fso.OpenTextFile(File,1).ReadAll
  27. Str = Replace(Str,OldStr,NewStr)
  28. fso.OpenTextFile(File,2,True).Write Str
  29. End If
  30. Next
  31. For Each folder In objFolder.SubFolders
  32. ErgodicFolder folder
  33. Next
  34. End Sub
  35. Sub UnZip(myZipFile, myTargetDir)
  36.     Set fso = CreateObject("Scripting.FileSystemObject")
  37.     If Not fso.FileExists(myZipFile) Then
  38.         Exit Sub
  39.     ElseIf fso.GetExtensionName(myZipFile) <> "zip" Then
  40.         Exit Sub
  41.     ElseIf Not fso.FolderExists(myTargetDir) Then
  42.         fso.CreateFolder(myTargetDir)
  43.     End If
  44.     myZipFile=fso.GetFile(myZipFile).Path
  45.     myTargetDir=fso.GetFolder(myTargetDir).Path
  46.     Set objShell = CreateObject("Shell.Application")
  47.     Set objSource = objShell.NameSpace(myZipFile)
  48.     Set objFolderItem = objSource.Items()
  49.     Set objTarget = objShell.NameSpace(myTargetDir)
  50.     intOptions = 256
  51.     objTarget.CopyHere objFolderItem, intOptions
  52. End Sub
  53. Sub Zip(mySourceDir, myZipFile)
  54.     Set fso = CreateObject("Scripting.FileSystemObject")
  55.     If fso.GetExtensionName(myZipFile) <> "zip" Then
  56.         Exit Sub
  57.     ElseIf fso.FolderExists(mySourceDir) Then
  58.         FType = "Folder"
  59.     ElseIf fso.FileExists(mySourceDir) Then
  60.         FType = "File"
  61.         FileName = fso.GetFileName(mySourceDir)
  62.         FolderPath = fso.GetFile(mySourceDir).ParentFolder
  63.     Else
  64.         Exit Sub
  65.     End If
  66.     Set f = fso.CreateTextFile(myZipFile, True)
  67.     f.Write "PK" & Chr(5) & Chr(6) & String(18, Chr(0))
  68.     f.Close
  69.     myZipFile=fso.GetFile(myZipFile).Path
  70.     Set objShell = CreateObject("Shell.Application")
  71.     Select Case Ftype
  72.         Case "Folder"
  73.         Set objSource = objShell.NameSpace(mySourceDir)
  74.         Set objFolderItem = objSource.Items()
  75.         Case "File"
  76.         Set objSource = objShell.NameSpace(FolderPath)
  77.         Set objFolderItem = objSource.ParseName(FileName)
  78.     End Select
  79.     Set objTarget = objShell.NameSpace(myZipFile)
  80.     intOptions = 256
  81.     objTarget.CopyHere objFolderItem, intOptions
  82.     Do
  83.         WScript.Sleep 1000
  84.     Loop Until objTarget.Items.Count > 0
  85. End Sub
复制代码
1

评分人数

TOP

返回列表