How to pass multiple files to zip in a single command using 7 zip?

I have one folder which will contain below mentioned files:

destiny.txt
destiny1.txt
destiny2.txt
destiny3.txt
destiny4.txt
destiny5.txt
destiny6.txt
destiny7.txt

Out of which destiny1.txt, destiny4.txt, destiny6.txt are from batch1.

I am using 7zip to zip the files.

Can I pass these 3 files in a single step to create DestinyTest.zip?

Is it possible?


Can I pass these 3 files in a single step to create DestinyTest.zip?

You can use the command line version of 7zip which is 7z.

From a command line:

7z a -tzip DestinyTest.zip destiny1.txt destiny4.txt destiny6.txt
  • a - Adds files to archive.
  • -tzip - Specifies the type of archive (we are creating a zip archive).

Further reading

  • 7zip Command Line Syntax
  • 7zip Command Line Switches
  • 7zip Command Line Examples

If you have a file listing the files to make the zip, eg

create a list of files to archive, one on each line. This is an @-list, from DOS days, a number of proggies will do this for each line.

You can create such a file with dir /b destin*.* > zipme.lst, and then remove lines in a ascii editor (notepad or edit).

type zipme.lst destiny1.txt destiny4.txt destiny6.txt 7za a -tzip DestinyTest.zip @zipme.lst

This will find zipme.lst, and add all the files listed in it. It can be longer than the command-line, and you have some control over it.