9

Is there a way to extract a 7z archive that contains all it's files within a directory without creating this directory in the file system but still keeping the sub-directory structure of the archive (so 7z e ... is not working as desired, because it strips all path info)?

In tar I would use tar -x --strip=1 ... to strip the first path component. Is there some equivalent for 7z or do I have to extract with the unwanted path segment, move the contents to the right place and delete the directory?

  • 1
    Looking at 7z command line options, I don't it's possible in one shot. Probably use 7z x to create the structure, 7z e to strip path info and then delete the files created by 7z x, tried it, it's still not what you want. – Sathyajith Bhat May 7 '12 at 4:17
  • Although you can't do this while extracting, you can strip the archive root folder when compressing. Instead of 7z a archive.7z path\to\folder do 7z a archive.7z path\to\folder\* to strip folder from the archived path name. – jpaugh Aug 1 '18 at 17:21
0

This can be done by using the GUI.

  1. Navigate within the archive to the directory you want.
  2. Select either that directory or its contents.
  3. Either
    • drag-and-drop it (or its contents) to a folder in your file manager; or
    • use the 7-Zip GUI's Extract button.

(Apologies in advance if a graphical solution is no good; I wasn't sure from my reading of your question.)

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.