8
 7za a -t7z -mmt -mx9 -y Include.7z .\Include\*

The above command adds the files to the 7z archive, but what if I want them in a custom subfolder?

For example Files\ inside .7z

  • Check the help and look through options: -o {OutputDir} – Przemek M Oct 16 '15 at 23:58
5

It appears that the developer himself has answered this question when you asked him:

Now there is no option for that task.

You can use additional "rn" (Rename) command to rename folder inside archive.

By experimenting, I found that alternatively, you can create the folder structure that you want to be added. Let your "staging area" refer to the place on your filesystem where you prepare the files/folders to be added... For your example, you could

  • Create a new (empty) Include folder in your staging area.
  • Put any new files and subfolders you want added beneath it in the archive under there.
  • Add them to the archive using the same command as in the question. (The a command in 7za a... means "add to archive", so it's the same command whether or not the archive exists yet.)

Using this method,

  • Any files in the archive that are not in your staging area will remain intact.
  • Any files/folders in the staging area, but not in the archive will be added.
  • Any files in both places will be overwritten in the archive with the new one from your staging area.
| improve this answer | |
0

Try this:

"C:\Program Files\7-Zip\7z.exe" a C:\deploy\TOP.ear C:\apps\temp\entidadejar\lib

Add the folder lib in TOP.ear, if a subfolder exists, the 7z will add the files inside the subfolder lib.

| improve this answer | |
  • Was the dot (.) after C:\apps\temp\entidadejar\lib meant to be part of the command,  or was it just the end of the sentence? – Scott Aug 30 '18 at 18:31
  • TOP.ear can be changed to TOP.zip or TOP.7z – Luana Ornelas Aug 31 '18 at 17:49
  • Was the dot (.) after C:\apps\temp\entidadejar\lib meant to be part of the command,  or was it just the end of the sentence? – Scott Aug 31 '18 at 17:51

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.