I've read several questions on this forum on how to do this but cannot find a way to do this via p7zip. I want to basically have p7zip go through a a directory and turn each top level directory in that directory into a zip or 7zip file. So for example I cd to directory a. I want directory b, c, d, e, etc to turn into their respective compressed files. I'm not an advanced user with the command line. I will get there, so bare with me in asking this question. p7zip by the way is a compression utility that does rar, zip and more through a command line interface.



On Linux/Unix you still have to use tar in order to backup directories. p7zip is still just a file compressor:

tar cf - [directory a] | 7z a -si [filename].tar.7z

  • Actually it is not. I can do on m mac 7z a filename.7z path/to/directory. For example dropbox.com/s/wakwcxpz7t8xpg6/… I've done this on a linux machine running p7zip as well. – user57081 Dec 13 '16 at 4:16
  • That's pretty special then since this is straight from from the p7zip documentation from the author: – A H Dec 13 '16 at 17:43
  • On Linux/Unix, in order to backup directories you must use tar ! to backup a directory : tar cf - directory | 7za a -si directory.tar.7z to restore your backup : 7za x -so directory.tar.7z | tar xf - – A H Dec 13 '16 at 17:43
  • The author specifically warns against using the -r flag to recurse directories if you're making backups because it will not get all that hidden files and directories that begin with a dot. He specifically says you need to use tar. – A H Dec 13 '16 at 17:47
  • I never wanted to back up directories. I'm zipping them or in this case trying to run a batch compression to make uploading easier, or in some user's case downloading. So there must be away. As shown I did do this in my example. I did 7zip a directory, or in this case archive a directory using p7zip. – user57081 Dec 17 '16 at 19:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.