10

Let's say there are 3 folders:

/a/1
/b/1
/c/1

And any of the folders may contain sub folders like

/a/1/x
/b/1/y
...

How to compress /a/1 /b/1 /c/1 folder with files and sub folders into same one 7z file and keep path info well in the package?

Al3n
  • 184

1 Answers1

14
7za a Test a b c

will create Test.7z with the three folders and all sub-folders and files stored using relative paths.

If you want to store the folders beginning at the second level, you can use:

7za a Test a\1 b\1 c\1
Karan
  • 56,477
  • 7za.exe is the command line version. You can use 7z.exe too, assuming you use Windows. – Karan Apr 13 '15 at 07:34
  • I've tried (p7za) 7za a Test a\1 b\1 c\1, it says Duplicate filename: 1 1 (Yes, a b c is not acceptable because they contain other files no need to package, the problem is there are folders with the same name 1). – Al3n Apr 13 '15 at 07:47
  • @Al3n: Do you want to preserve the entire depth of the tree structure or just the local structure? If you store the full path for each stored directory, you avoid the duplicate names problem, but unzipping gives you either the original structure depth or no structure, so you couldn't retain the local structure attached to a different directory. If that's a problem, consider zipping each local tree separately to avoid the name duplication, and then zip the zip files into one umbrella file. – fixer1234 Apr 13 '15 at 08:13
  • @Al3n: I tested both commands with 7za.exe and they work with no such error. Could be a p7za limitation perhaps, although I can't understand why it's complaining about duplicate filenames when they're actually folders. – Karan Apr 13 '15 at 19:24
  • @fixer1234 Keep the structure under "1" would be Ok. I originally compress them in different zip packages. I'm wandering put folders in one package to utilize solid compression to reduce total size. – Al3n Apr 14 '15 at 09:02
  • @Karan I've got success. Thanks. I was using absolute path(OS X 10.10.2, path is like /Volumes/xxx/a/1) firstly. There's no error while using relative path. – Al3n Apr 14 '15 at 09:31
  • @Al3n: Ah, in your comment above you used relative paths, and so did I in my answer. If you'd indicated you were using absolute paths that might have raised some flags. Anyway good you managed to solve it. – Karan Apr 14 '15 at 18:42
  • @Karan My bad. I should use the same sample paths instead of abstractions. – Al3n Apr 15 '15 at 00:17