Follow us on Twitter

How Do You Zip and Password Protect Files In as Few Steps as Possible?


If you have a large batch of files to compress and you want to add password protection to each of them, what is the simplest or quickest way to do so? Today’s SuperUser Q&A post has the answer to a curious reader’s question.

Today’s Question & Answer session comes to us courtesy of SuperUser—a subdivision of Stack Exchange, a community-driven grouping of Q&A web sites.

The Question

SuperUser reader DAE wants to know how to zip and password protect files in as few steps as possible:

I need a way to take a bunch of files and compress them into separate zip files with each using the same password. I want to be able to do this in one simple step. I have created a batch file that zips each of them using 7zip (which worked perfectly), but does not password protect them.

Is there a command that I can add to the batch file that includes the password? Or alternatively, how can I create a batch file that will password protect the compressed files?

How do you zip and password protect files in as few steps as possible?

The Answer

SuperUser contributor DavidPostill has the answer for us:

How can I create a batch file that will password protect the compressed files?

Use the -p option, -p (set password) switch, which specifies the password.

Syntax

{password} specifies the password

Examples

Compresses *.txt files to archive.7z using the password “secret”. It also encrypts archive headers (-mhe switch) so that the file names will be encrypted.

  • 7z a archive.7z -psecret -mhe *.txt

If compressing folders:

  • “C:Program Files (x86)7-Zip7z.exe” a “%%X.zip” -psecret “%%X”

Extracts all files from archive.zip using the password “secret”.

  • 7z x archive.zip -psecret

Source: -p (set Password) switch


Have something to add to the explanation? Sound off in the comments. Want to read more answers from other tech-savvy Stack Exchange users? Check out the full discussion thread here.

Akemi Iwaya is a devoted Mozilla Firefox user who enjoys working with multiple browsers and occasionally dabbling with Linux. She also loves reading fantasy and sci-fi stories as well as playing “old school” role-playing games. You can visit her on Twitter and .


How to Restart Your Plex Media Server
Are Razer’s zSilver Gaming Rewards Worth It?

Comments

comments