目前,我可以通过在输入中传递文件名来提取.gz文件。但是,我想提取目录中存在的所有.gz文件。请仔细阅读并帮助解决该问题。
代码:
input = "C:\Src_csv\ExtractionFile\Axy.txt.gz"
output = "C:\Src_csv\Extraction\Dest\"
Call Unzip(input, output)
Function UnZip(ByVal input, ByVal output)
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oShell = CreateObject("Wscript.Shell")
'Set xfolder = objfso.GetFolder(input)
If oFSO.FileExists("C:\Program files\7-Zip\7Z.exe") Then 'Update the 7zip file path
s7zLocation = "C:\Program files\7-Zip\" 'Update the 7zip file path
Else
UnZip = "Error: Couldn't find 7z.exe"
Exit Function
End If
'Ensure we can find archive to uncompress
If Not oFSO.FileExists(input) Then
UnZip = "Error: File Not Found."
Exit Function
End If
For Each
oShell.Run """" & s7zLocation & "7z.exe"" e -y -o""" & output & _
""" """ & input & """", 0, True
UnZip = 1
End Function