所以我在这里遵循了解决方案: 将多个目录压缩到单独的 zip 文件中的命令
我在命令中添加了 -er 但正如我所料,我需要输入每个循环操作的密码,即每个压缩的文件夹的密码。
如何自动化密码部分?我想对所有压缩文件使用相同的密码。
谢谢
编辑:如果我可以在另一个目录中创建所有输出 zip 文件,那就太好了
答案1
您可以使用 -P 标志来代替 -er 标志 - 它期望后面跟着密码。
-P password
--password password
Use password to encrypt zipfile entries (if any). THIS IS INSE-
CURE! Many multi-user operating systems provide ways for any
user to see the current command line of any other user; even on
stand-alone systems there is always the threat of over-the-
shoulder peeking. Storing the plaintext password as part of a
command line in an automated script is even worse. Whenever
possible, use the non-echoing, interactive prompt to enter pass-
words. (And where security is truly important, use strong
encryption such as Pretty Good Privacy instead of the relatively
weak standard encryption provided by zipfile utilities.)
请注意,它是不安全的,因为密码显示在命令行上,并且可能被查看进程树的其他人看到。
如果这是不可接受的,请考虑使用 Expect 实用程序。