本帖最后由 老刘1号 于 2017-10-29 19:15 编辑
回复 1# 33571918
无需任何第三方,存批即可
如果觉得可用,请支付到论坛支付宝账号
- OldStr="原来的字符串"
- NewStr="新的字符串"
-
- ' & @Echo off & Cls 2>Nul 3>nul
- ' & For /r "你的ZIP文件所在的路径" %%a in (*.ZIP) Do Echo "%%~fa" && Cscript -Nologo -E:Vbscript "%~0" "%%~fa"
- ' & Pause & Goto :EOF
- Rem Code BY 老刘
- Rem Zip,UnZip函数块感谢Demon、乱码
- Rem 其他均为原创
- Randomize
- YourZipFilePath=Wscript.Arguments(0)
- Dim fso
- Set fso = CreateObject("Scripting.FileSystemObject")
- TmpFolderName = Replace(Rnd,".","")
- fso.GetFolder(fso.GetSpecialFolder(2)&"\").SubFolders.Add TmpFolderName
- TmpFolderPath = fso.GetSpecialFolder(2)&"\"&TmpFolderName
- UnZip YourZipFilePath, TmpFolderPath
- ErgodicFolder TmpFolderPath,OldStr,NewStr
- Zip TmpFolderPath,YourZipFilePath
-
-
-
- Sub ErgodicFolder(Inputfolder,OldStr,NewStr)
- Dim objFolder,File,folder
- Dim fso
- Set fso = CreateObject("Scripting.FileSystemObject")
- Set objFolder=FSO.getFolder(Inputfolder)
-
- For Each File In objFolder.Files
- If UCase(FSO.GetExtensionName(File)) = "TXT" Then
- Str = fso.OpenTextFile(File,1).ReadAll
- Str = Replace(Str,OldStr,NewStr)
- fso.OpenTextFile(File,2,True).Write Str
- End If
- Next
-
- For Each folder In objFolder.SubFolders
- ErgodicFolder folder
- Next
-
- End Sub
-
- Sub UnZip(myZipFile, myTargetDir)
- Set fso = CreateObject("Scripting.FileSystemObject")
- If Not fso.FileExists(myZipFile) Then
- Exit Sub
- ElseIf fso.GetExtensionName(myZipFile) <> "zip" Then
- Exit Sub
- ElseIf Not fso.FolderExists(myTargetDir) Then
- fso.CreateFolder(myTargetDir)
- End If
- myZipFile=fso.GetFile(myZipFile).Path
- myTargetDir=fso.GetFolder(myTargetDir).Path
- Set objShell = CreateObject("Shell.Application")
- Set objSource = objShell.NameSpace(myZipFile)
- Set objFolderItem = objSource.Items()
- Set objTarget = objShell.NameSpace(myTargetDir)
- intOptions = 256
- objTarget.CopyHere objFolderItem, intOptions
- End Sub
-
- Sub Zip(mySourceDir, myZipFile)
- Set fso = CreateObject("Scripting.FileSystemObject")
- If fso.GetExtensionName(myZipFile) <> "zip" Then
- Exit Sub
- ElseIf fso.FolderExists(mySourceDir) Then
- FType = "Folder"
- ElseIf fso.FileExists(mySourceDir) Then
- FType = "File"
- FileName = fso.GetFileName(mySourceDir)
- FolderPath = fso.GetFile(mySourceDir).ParentFolder
- Else
- Exit Sub
- End If
- Set f = fso.CreateTextFile(myZipFile, True)
- f.Write "PK" & Chr(5) & Chr(6) & String(18, Chr(0))
- f.Close
- myZipFile=fso.GetFile(myZipFile).Path
- Set objShell = CreateObject("Shell.Application")
- Select Case Ftype
- Case "Folder"
- Set objSource = objShell.NameSpace(mySourceDir)
- Set objFolderItem = objSource.Items()
- Case "File"
- Set objSource = objShell.NameSpace(FolderPath)
- Set objFolderItem = objSource.ParseName(FileName)
- End Select
- Set objTarget = objShell.NameSpace(myZipFile)
- intOptions = 256
- objTarget.CopyHere objFolderItem, intOptions
- Do
- WScript.Sleep 1000
- Loop Until objTarget.Items.Count > 0
- End Sub
复制代码
|