在 Windows 7 cmd 上壓縮/解壓縮我的目錄

在 Windows 7 cmd 上壓縮/解壓縮我的目錄

我想壓縮一個包含多種類型檔案和其中許多子目錄的目錄。我試過:

compact /c file

但我什麼也沒看到。接下來我找到了 zip/unzip 命令並嘗試了:

zip file.zip file

有效。但是,有一些子目錄包含內容(在壓縮之前的輸入資料夾中),而現在,在壓縮檔案中,在該子目錄中,沒有內容。這意味著在壓縮期間它沒有儲存子目錄的內容。什麼 DOS 指令(僅)可以幫助我解決問題。

答案1

使用-r以下選項:

zip -r foo.zip foo

這將告訴 zip 遞歸目錄foo

答案2

或者,您可以使用 PowerShell v5.0+。

壓縮:

Compress-Archive -LiteralPath 'C:\mypath\testfile.txt' -DestinationPath "C:\mypath\Test.zip"

解壓縮:

Expand-Archive -LiteralPath "C:\mypath\Test.Zip" -DestinationPath "C:\mypath" -Force

資料來源:

特別感謝@Ramhound

相關內容