2014-03-07 85 views
0

我希望能夠創建一個批處理腳本,將壓縮命令中指定的目錄。然後我想將其稱爲info.zip。任何幫助將是美好的!謝謝。批處理代碼來壓縮文件夾?

+0

可能重複(http://stackoverflow.com/questions/30211/can-windows-built-in- zip-compression-be-scripted) – Mark

回答

0

您可以使用7zip,可以從命令行調用大量參數。你可以找到一些很好的例子here

+0

有沒有辦法做到這一點,而無需安裝任何東西?我真的不在乎是否必須使用Visual Basic或其他任何東西。 – drcomputer

+0

Windows不具備通過命令行執行此操作的原生功能。 – 09stephenb

+0

將7zip部署在共享文件系統上對於這種類型的腳本來說總是很有用。我建議部署它,它會爲您節省大量時間,並可以被很多不同的腳本使用 –

0

試試這個適合的編輯器。

Dim fso, winShell, MyTarget, MySource, file 
Set fso = CreateObject("Scripting.FileSystemObject") 
Set winShell = createObject("shell.application") 


MyTarget = Wscript.Arguments.Item(0) 
MySource = Wscript.Arguments.Item(1) 

Wscript.Echo "Adding " & MySource & " to " & MyTarget 

'create a new clean zip archive 
Set file = fso.CreateTextFile(MyTarget, True) 
file.write("PK" & chr(5) & chr(6) & string(18,chr(0))) 
file.close 

winShell.NameSpace(MyTarget).CopyHere winShell.NameSpace(MySource).Items 

do until winShell.namespace(MyTarget).items.count = winShell.namespace(MySource).items.count 
    wscript.sleep 1000 
loop 

Set winShell = Nothing 
Set fso = Nothing 

來源:[?能否Windows內置的ZIP壓縮編寫腳本] Can Windows' built-in ZIP compression be scripted?

相關問題