There's lots of questions asking how to add only files with a particular file extension to an archive, but to my great surprise it seems like no one wants to add a single file to an archive.

How do I add a single specific file to an archive with the 7-Zip command line?

  • You can expect within the command line structure that a wildcard can be replaced with a single filename, or as RaziAbbasi notes in his answer, a list of filenames. – fred_dot_u Feb 6 '18 at 1:20

The approach would be the same, just the bit at the end would be a little different.

So for a particular file extension you would do this:

7z a -t7z archive.7z *.txt 

You have just added all the .txt files.

But let's say you want to add a pdf and a doc to that, you would do this:

7z a -t7z archive.7z file.pdf file2.doc

Note: This won't create a new archive.7z, rather it will just add file.pdf and file2.doc to the archive.7z you created earlier.

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.