如何解压缩7z zip并具有正确的目录结构?


34
XXXhostXXX:temp XXXuserXXX$ ls -a dir1/
.   ..  a.txt   b.txt
XXXhostXXX:temp XXXuserXXX$ pwd
/Users/XXXuserXXX/temp
XXXhostXXX:temp XXXuserXXX$ 7z a -t7z dir1 dir1

7-Zip [64] 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18
p7zip Version 9.20 (locale=utf8,Utf16=on,HugeFiles=on,4 CPUs)
Scanning

Creating archive dir1.7z

Compressing  dir1/a.txt      
Compressing  dir1/b.txt      

Everything is Ok
XXXhostXXX:temp XXXuserXXX$ ls
dir1    dir1.7z
XXXhostXXX:temp XXXuserXXX$ mkdir tmp
XXXhostXXX:temp XXXuserXXX$ mv dir1.7z tmp/.
XXXhostXXX:temp XXXuserXXX$ cd tmp/
XXXhostXXX:tmp XXXuserXXX$ ls
dir1.7z
XXXhostXXX:tmp XXXuserXXX$ 7z e dir1.7z 

7-Zip [64] 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18
p7zip Version 9.20 (locale=utf8,Utf16=on,HugeFiles=on,4 CPUs)

Processing archive: dir1.7z

Extracting  dir1/a.txt
Extracting  dir1/b.txt
Extracting  dir1

Everything is Ok

Folders: 1
Files: 2
Size:       58
Compressed: 216
XXXhostXXX:tmp XXXuserXXX$ ls
a.txt   b.txt   dir1    dir1.7z
XXXhostXXX:tmp XXXuserXXX$ 
XXXhostXXX:tmp XXXuserXXX$ ls -a dir1
.       ..

为什么最后a.txtb.txt被淘汰出局dir1

Answers:


69

看来您可能想尝试使用x命令而不是e。例如

7za x test.7z

为我工作,并保留了完整的目录结构


7
谢谢,并+1,但我希望这种带有“ e”的行为不存在!我的主文件夹中现在有2147个文件,可能是10个或20个文件:'(((((
Shautieh
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.