
我想壓縮該資料夾C:\Temp
,但沒有特定的子資料夾(例如C:\Temp\test
)。我怎麼才能用 7zip 做到這一點?
我想出了以下命令:
c:\Temp>7zip a -t7z test.7z c:\temp\ -mx0 -x!c:\temp\test\*
但它不起作用,因為輸出是:
7-Zip (A) 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18
Scanning
Updating archive test.7z
Compressing Temp\admin.PNG
Compressing Temp\test\admin2.PNG <<<<<< this file should not be added to the archive
Compressing Temp\first.txt
答案1
在我的系統上測試過:
7zip a -t7z -mx0 -x!test\* test.7z c:\temp\
如果您位於來源目錄中,檔案將使用相對路徑存儲,因此測試資料夾看起來像test\file1.txt
,而不是c:\temp\test\file1.txt
。
請注意,使用 -mx0 開關,您不會壓縮文件,只是將它們完整複製到存檔中。