10
 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

bertieb
  • 7,405

3 Answers3

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.
cp.engr
  • 242
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.

0

The command to do this is rn. From https://sevenzip.osdn.jp/chm/cmdline/commands/rename.htm:

7z rn <archive_name> <src_file_1> <dest_file_1> [ <src_file_2> <dest_file_2> ... ]
qwr
  • 732