How to extract 7z zip and have correct directory strucuture?

35

7

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
.       ..

Why at the end a.txt and b.txt were taken out of dir1?

qazwsx

Posted 2012-01-17T21:50:24.980

Reputation: 6 739

Answers

70

It looks like you may want to try the x command instead of the e. For example

7za x test.7z

worked for me and preserved full directory structures

Dennis

Posted 2012-01-17T21:50:24.980

Reputation: 5 768

7Thanks and +1, but I wish this behaviour with "e" wouldn't exist!! My home folder now has 2147 files in it, up from maybe 10 or 20 :'((((( – Shautieh – 2015-09-16T19:13:20.763