lets say that I have a folder containing 250 more folders (f1,..f250) and I want to zip each of these 250 folders into an individual zip-file that is password protected. I found this answer with the following code

for i in * ; do zip -vr "$i.zip" "$i" ; mv "$i.zip" /move/zipfiles/here/ ; done

and tried to adapt that to my situation combining it with

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

which I found here. My result so far

for i in * ; do 7z a "$i.zip" -ppassword "$i" ; done

This does create multiple zip files that are named f1.zip,...f250.zip but each of these zip files is empty. If I run the single command

7z a f1.zip -ppassword f1

everything gets packed correctly. Can anyone point out where I am going wrong?

1 Answer 1


I found a solution yet I don't know why this now works/why the solution I found in the first link does not.

If I get rid of the quotation marks and run it as

for i in * ; do 7z a $i.zip -ppassword $i ; done

everything seems to be working fine. If anybody feels like commenting on why the quotation marks are not needed, I would appreciate that.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .