Password protect multiple individual ZIP files on Mac
Currently, I have an Automator script (Shell Script) which allows me to select multiple files and then create an individual zip file for each.
for f in "$@"
do
zip -j "$f.zip" "$f"
done
What I'd like to do is the same thing, but to set a password for each individual file as well. Any help is appreciated!
mac encryption zip password-protection
add a comment |
Currently, I have an Automator script (Shell Script) which allows me to select multiple files and then create an individual zip file for each.
for f in "$@"
do
zip -j "$f.zip" "$f"
done
What I'd like to do is the same thing, but to set a password for each individual file as well. Any help is appreciated!
mac encryption zip password-protection
How would you tell zip the password? Should it be the same for every file, or should it be a keyfile/passphrase-file?
– Xen2050
Feb 5 at 10:34
Hi @Xen2050, the password should be the same for every file.
– Harry
Feb 6 at 19:56
add a comment |
Currently, I have an Automator script (Shell Script) which allows me to select multiple files and then create an individual zip file for each.
for f in "$@"
do
zip -j "$f.zip" "$f"
done
What I'd like to do is the same thing, but to set a password for each individual file as well. Any help is appreciated!
mac encryption zip password-protection
Currently, I have an Automator script (Shell Script) which allows me to select multiple files and then create an individual zip file for each.
for f in "$@"
do
zip -j "$f.zip" "$f"
done
What I'd like to do is the same thing, but to set a password for each individual file as well. Any help is appreciated!
mac encryption zip password-protection
mac encryption zip password-protection
edited Feb 11 at 10:29
Ahmed Ashour
1,3621716
1,3621716
asked Feb 5 at 3:52
HarryHarry
31
31
How would you tell zip the password? Should it be the same for every file, or should it be a keyfile/passphrase-file?
– Xen2050
Feb 5 at 10:34
Hi @Xen2050, the password should be the same for every file.
– Harry
Feb 6 at 19:56
add a comment |
How would you tell zip the password? Should it be the same for every file, or should it be a keyfile/passphrase-file?
– Xen2050
Feb 5 at 10:34
Hi @Xen2050, the password should be the same for every file.
– Harry
Feb 6 at 19:56
How would you tell zip the password? Should it be the same for every file, or should it be a keyfile/passphrase-file?
– Xen2050
Feb 5 at 10:34
How would you tell zip the password? Should it be the same for every file, or should it be a keyfile/passphrase-file?
– Xen2050
Feb 5 at 10:34
Hi @Xen2050, the password should be the same for every file.
– Harry
Feb 6 at 19:56
Hi @Xen2050, the password should be the same for every file.
– Harry
Feb 6 at 19:56
add a comment |
1 Answer
1
active
oldest
votes
Since you're using a shell script already, I was assuming you have access to bash's read
command to read input to a variable, and a similar zip
command to Debian's, so you could first store the password to the variable $pass
with:
read -rsp "enter password" pass
Where the options mean (from man bash
or help read
):
-p prompt output the string PROMPT without a trailing newline before
attempting to read
-r do not allow backslashes to escape any characters
-s do not echo input coming from a terminal
If you're using a more basic shell like /bin/sh
/ dash, it's read command does not have the -s
option.
Then zip the files with:
zip -j -e -P "$pass" "$f.zip" "$f"
Note from zip's man page:
-P password
--password password
Use password to encrypt zipfile entries (if any). THIS IS INSECURE! 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, inter‐
active prompt to enter passwords. (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.)
If you're on your own private secure computer with no one watching you, then I wouldn't worry about the potential insecurity of using a password like this.
Or you could omit the password storing & zip's -P
option, and let zip prompt you for the password (twice) for each file.
All together, asking for a password once would look like this:
read -rsp "enter password" pass
# If you don't mind seeing the password, it would be safe to verify it:
echo -e "nUsing this password: $pass"
read -r -n1 -p "Press any key to continue..."
echo
for f in "$@"
do
zip -j -e -P "$pass" "$f.zip" "$f"
done
Or read the password twice in a loop, until the two passwords match:
until [ "$pass" == "$pass2" ]; do
read -r -p "Enter password" pass
read -r -p "Enter password again" pass2
done
for f in "$@"
do
zip -j -e -P "$pass" "$f.zip" "$f"
done
It appears there was a problem with the assumption that bash's read
would work, your automator script isn't running in a regular terminal so you can't get to it's standard input. Here's some other ideas that might work.
Use bash to ask for more input
From https://discussions.apple.com/thread/7216062?answerId=28893979022#28893979022
Hiroto User level: Level 5 (7,463 points)
Sep 15, 2015 2:57 AM in response to Scotsman
Hello
Also you might do everything from shell. Something like this.
#!/bin/bash
ask () {
osascript <<EOF - 2>/dev/null
tell application "SystemUIServer"
activate
text returned of (display dialog "$1" default answer "")
end tell
EOF
}
FROM=$( ask 'Enter value for --from' ) || exit
CREDITS=$( ask 'Enter value for --credits' ) || exit
CAPACITY=$( ask 'Enter value for --capacity' ) || exit
LY_PER=$( ask 'Enter value for --ly-per' ) || exit
trade.py run --from "$FROM" --credits "$CREDITS" --capacity "$CAPACITY" --ly-per "$LY_PER"
Regards,
H
- Once you've got the ask function working, you could only ask for the password (the above example looks like it asks for parameters to run python or something, all you'd need is the ask).
Run the whole script in a terminal
If you could have it run in a terminal then read
should work.
Get automator to ask you for more input
Apparently this question on apple.stackexchange.com looks there's a way to have automator "Ask for text" to try getting another variable.
Thanks Xen. How would I enter all of this into a single Automator script (or two separate scripts, one for the zipping, and one for password protecting)? Much appreciated.
– Harry
Feb 11 at 0:01
If you're using zip, I think it has to compress and password in the same (single) command. But you'd just put theread ...
command before the for loop, putting it inside the for loop would read a password for each file (if you wanted different passwords). I'll edit it all together at the end of my answer. PS If the answer's useful or the "best" then please do accept it &/or vote it up, thanks :)
– Xen2050
Feb 11 at 7:22
Thanks Xen, I couldn't get the above scripts to work, what I ended up doing was setting the pass variable in the script. See:pass=password for f in "$@" do zip -j -e -P "$pass" "$f.zip" "$f" done
Thanks.
– Harry
Feb 13 at 2:52
That works too, and no typing errors either. I think I see the problem, your script isn't running in a regular terminal, so can'tread
from standard input... I'll edit in an idea or two.
– Xen2050
Feb 13 at 11:56
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1402096%2fpassword-protect-multiple-individual-zip-files-on-mac%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Since you're using a shell script already, I was assuming you have access to bash's read
command to read input to a variable, and a similar zip
command to Debian's, so you could first store the password to the variable $pass
with:
read -rsp "enter password" pass
Where the options mean (from man bash
or help read
):
-p prompt output the string PROMPT without a trailing newline before
attempting to read
-r do not allow backslashes to escape any characters
-s do not echo input coming from a terminal
If you're using a more basic shell like /bin/sh
/ dash, it's read command does not have the -s
option.
Then zip the files with:
zip -j -e -P "$pass" "$f.zip" "$f"
Note from zip's man page:
-P password
--password password
Use password to encrypt zipfile entries (if any). THIS IS INSECURE! 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, inter‐
active prompt to enter passwords. (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.)
If you're on your own private secure computer with no one watching you, then I wouldn't worry about the potential insecurity of using a password like this.
Or you could omit the password storing & zip's -P
option, and let zip prompt you for the password (twice) for each file.
All together, asking for a password once would look like this:
read -rsp "enter password" pass
# If you don't mind seeing the password, it would be safe to verify it:
echo -e "nUsing this password: $pass"
read -r -n1 -p "Press any key to continue..."
echo
for f in "$@"
do
zip -j -e -P "$pass" "$f.zip" "$f"
done
Or read the password twice in a loop, until the two passwords match:
until [ "$pass" == "$pass2" ]; do
read -r -p "Enter password" pass
read -r -p "Enter password again" pass2
done
for f in "$@"
do
zip -j -e -P "$pass" "$f.zip" "$f"
done
It appears there was a problem with the assumption that bash's read
would work, your automator script isn't running in a regular terminal so you can't get to it's standard input. Here's some other ideas that might work.
Use bash to ask for more input
From https://discussions.apple.com/thread/7216062?answerId=28893979022#28893979022
Hiroto User level: Level 5 (7,463 points)
Sep 15, 2015 2:57 AM in response to Scotsman
Hello
Also you might do everything from shell. Something like this.
#!/bin/bash
ask () {
osascript <<EOF - 2>/dev/null
tell application "SystemUIServer"
activate
text returned of (display dialog "$1" default answer "")
end tell
EOF
}
FROM=$( ask 'Enter value for --from' ) || exit
CREDITS=$( ask 'Enter value for --credits' ) || exit
CAPACITY=$( ask 'Enter value for --capacity' ) || exit
LY_PER=$( ask 'Enter value for --ly-per' ) || exit
trade.py run --from "$FROM" --credits "$CREDITS" --capacity "$CAPACITY" --ly-per "$LY_PER"
Regards,
H
- Once you've got the ask function working, you could only ask for the password (the above example looks like it asks for parameters to run python or something, all you'd need is the ask).
Run the whole script in a terminal
If you could have it run in a terminal then read
should work.
Get automator to ask you for more input
Apparently this question on apple.stackexchange.com looks there's a way to have automator "Ask for text" to try getting another variable.
Thanks Xen. How would I enter all of this into a single Automator script (or two separate scripts, one for the zipping, and one for password protecting)? Much appreciated.
– Harry
Feb 11 at 0:01
If you're using zip, I think it has to compress and password in the same (single) command. But you'd just put theread ...
command before the for loop, putting it inside the for loop would read a password for each file (if you wanted different passwords). I'll edit it all together at the end of my answer. PS If the answer's useful or the "best" then please do accept it &/or vote it up, thanks :)
– Xen2050
Feb 11 at 7:22
Thanks Xen, I couldn't get the above scripts to work, what I ended up doing was setting the pass variable in the script. See:pass=password for f in "$@" do zip -j -e -P "$pass" "$f.zip" "$f" done
Thanks.
– Harry
Feb 13 at 2:52
That works too, and no typing errors either. I think I see the problem, your script isn't running in a regular terminal, so can'tread
from standard input... I'll edit in an idea or two.
– Xen2050
Feb 13 at 11:56
add a comment |
Since you're using a shell script already, I was assuming you have access to bash's read
command to read input to a variable, and a similar zip
command to Debian's, so you could first store the password to the variable $pass
with:
read -rsp "enter password" pass
Where the options mean (from man bash
or help read
):
-p prompt output the string PROMPT without a trailing newline before
attempting to read
-r do not allow backslashes to escape any characters
-s do not echo input coming from a terminal
If you're using a more basic shell like /bin/sh
/ dash, it's read command does not have the -s
option.
Then zip the files with:
zip -j -e -P "$pass" "$f.zip" "$f"
Note from zip's man page:
-P password
--password password
Use password to encrypt zipfile entries (if any). THIS IS INSECURE! 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, inter‐
active prompt to enter passwords. (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.)
If you're on your own private secure computer with no one watching you, then I wouldn't worry about the potential insecurity of using a password like this.
Or you could omit the password storing & zip's -P
option, and let zip prompt you for the password (twice) for each file.
All together, asking for a password once would look like this:
read -rsp "enter password" pass
# If you don't mind seeing the password, it would be safe to verify it:
echo -e "nUsing this password: $pass"
read -r -n1 -p "Press any key to continue..."
echo
for f in "$@"
do
zip -j -e -P "$pass" "$f.zip" "$f"
done
Or read the password twice in a loop, until the two passwords match:
until [ "$pass" == "$pass2" ]; do
read -r -p "Enter password" pass
read -r -p "Enter password again" pass2
done
for f in "$@"
do
zip -j -e -P "$pass" "$f.zip" "$f"
done
It appears there was a problem with the assumption that bash's read
would work, your automator script isn't running in a regular terminal so you can't get to it's standard input. Here's some other ideas that might work.
Use bash to ask for more input
From https://discussions.apple.com/thread/7216062?answerId=28893979022#28893979022
Hiroto User level: Level 5 (7,463 points)
Sep 15, 2015 2:57 AM in response to Scotsman
Hello
Also you might do everything from shell. Something like this.
#!/bin/bash
ask () {
osascript <<EOF - 2>/dev/null
tell application "SystemUIServer"
activate
text returned of (display dialog "$1" default answer "")
end tell
EOF
}
FROM=$( ask 'Enter value for --from' ) || exit
CREDITS=$( ask 'Enter value for --credits' ) || exit
CAPACITY=$( ask 'Enter value for --capacity' ) || exit
LY_PER=$( ask 'Enter value for --ly-per' ) || exit
trade.py run --from "$FROM" --credits "$CREDITS" --capacity "$CAPACITY" --ly-per "$LY_PER"
Regards,
H
- Once you've got the ask function working, you could only ask for the password (the above example looks like it asks for parameters to run python or something, all you'd need is the ask).
Run the whole script in a terminal
If you could have it run in a terminal then read
should work.
Get automator to ask you for more input
Apparently this question on apple.stackexchange.com looks there's a way to have automator "Ask for text" to try getting another variable.
Thanks Xen. How would I enter all of this into a single Automator script (or two separate scripts, one for the zipping, and one for password protecting)? Much appreciated.
– Harry
Feb 11 at 0:01
If you're using zip, I think it has to compress and password in the same (single) command. But you'd just put theread ...
command before the for loop, putting it inside the for loop would read a password for each file (if you wanted different passwords). I'll edit it all together at the end of my answer. PS If the answer's useful or the "best" then please do accept it &/or vote it up, thanks :)
– Xen2050
Feb 11 at 7:22
Thanks Xen, I couldn't get the above scripts to work, what I ended up doing was setting the pass variable in the script. See:pass=password for f in "$@" do zip -j -e -P "$pass" "$f.zip" "$f" done
Thanks.
– Harry
Feb 13 at 2:52
That works too, and no typing errors either. I think I see the problem, your script isn't running in a regular terminal, so can'tread
from standard input... I'll edit in an idea or two.
– Xen2050
Feb 13 at 11:56
add a comment |
Since you're using a shell script already, I was assuming you have access to bash's read
command to read input to a variable, and a similar zip
command to Debian's, so you could first store the password to the variable $pass
with:
read -rsp "enter password" pass
Where the options mean (from man bash
or help read
):
-p prompt output the string PROMPT without a trailing newline before
attempting to read
-r do not allow backslashes to escape any characters
-s do not echo input coming from a terminal
If you're using a more basic shell like /bin/sh
/ dash, it's read command does not have the -s
option.
Then zip the files with:
zip -j -e -P "$pass" "$f.zip" "$f"
Note from zip's man page:
-P password
--password password
Use password to encrypt zipfile entries (if any). THIS IS INSECURE! 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, inter‐
active prompt to enter passwords. (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.)
If you're on your own private secure computer with no one watching you, then I wouldn't worry about the potential insecurity of using a password like this.
Or you could omit the password storing & zip's -P
option, and let zip prompt you for the password (twice) for each file.
All together, asking for a password once would look like this:
read -rsp "enter password" pass
# If you don't mind seeing the password, it would be safe to verify it:
echo -e "nUsing this password: $pass"
read -r -n1 -p "Press any key to continue..."
echo
for f in "$@"
do
zip -j -e -P "$pass" "$f.zip" "$f"
done
Or read the password twice in a loop, until the two passwords match:
until [ "$pass" == "$pass2" ]; do
read -r -p "Enter password" pass
read -r -p "Enter password again" pass2
done
for f in "$@"
do
zip -j -e -P "$pass" "$f.zip" "$f"
done
It appears there was a problem with the assumption that bash's read
would work, your automator script isn't running in a regular terminal so you can't get to it's standard input. Here's some other ideas that might work.
Use bash to ask for more input
From https://discussions.apple.com/thread/7216062?answerId=28893979022#28893979022
Hiroto User level: Level 5 (7,463 points)
Sep 15, 2015 2:57 AM in response to Scotsman
Hello
Also you might do everything from shell. Something like this.
#!/bin/bash
ask () {
osascript <<EOF - 2>/dev/null
tell application "SystemUIServer"
activate
text returned of (display dialog "$1" default answer "")
end tell
EOF
}
FROM=$( ask 'Enter value for --from' ) || exit
CREDITS=$( ask 'Enter value for --credits' ) || exit
CAPACITY=$( ask 'Enter value for --capacity' ) || exit
LY_PER=$( ask 'Enter value for --ly-per' ) || exit
trade.py run --from "$FROM" --credits "$CREDITS" --capacity "$CAPACITY" --ly-per "$LY_PER"
Regards,
H
- Once you've got the ask function working, you could only ask for the password (the above example looks like it asks for parameters to run python or something, all you'd need is the ask).
Run the whole script in a terminal
If you could have it run in a terminal then read
should work.
Get automator to ask you for more input
Apparently this question on apple.stackexchange.com looks there's a way to have automator "Ask for text" to try getting another variable.
Since you're using a shell script already, I was assuming you have access to bash's read
command to read input to a variable, and a similar zip
command to Debian's, so you could first store the password to the variable $pass
with:
read -rsp "enter password" pass
Where the options mean (from man bash
or help read
):
-p prompt output the string PROMPT without a trailing newline before
attempting to read
-r do not allow backslashes to escape any characters
-s do not echo input coming from a terminal
If you're using a more basic shell like /bin/sh
/ dash, it's read command does not have the -s
option.
Then zip the files with:
zip -j -e -P "$pass" "$f.zip" "$f"
Note from zip's man page:
-P password
--password password
Use password to encrypt zipfile entries (if any). THIS IS INSECURE! 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, inter‐
active prompt to enter passwords. (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.)
If you're on your own private secure computer with no one watching you, then I wouldn't worry about the potential insecurity of using a password like this.
Or you could omit the password storing & zip's -P
option, and let zip prompt you for the password (twice) for each file.
All together, asking for a password once would look like this:
read -rsp "enter password" pass
# If you don't mind seeing the password, it would be safe to verify it:
echo -e "nUsing this password: $pass"
read -r -n1 -p "Press any key to continue..."
echo
for f in "$@"
do
zip -j -e -P "$pass" "$f.zip" "$f"
done
Or read the password twice in a loop, until the two passwords match:
until [ "$pass" == "$pass2" ]; do
read -r -p "Enter password" pass
read -r -p "Enter password again" pass2
done
for f in "$@"
do
zip -j -e -P "$pass" "$f.zip" "$f"
done
It appears there was a problem with the assumption that bash's read
would work, your automator script isn't running in a regular terminal so you can't get to it's standard input. Here's some other ideas that might work.
Use bash to ask for more input
From https://discussions.apple.com/thread/7216062?answerId=28893979022#28893979022
Hiroto User level: Level 5 (7,463 points)
Sep 15, 2015 2:57 AM in response to Scotsman
Hello
Also you might do everything from shell. Something like this.
#!/bin/bash
ask () {
osascript <<EOF - 2>/dev/null
tell application "SystemUIServer"
activate
text returned of (display dialog "$1" default answer "")
end tell
EOF
}
FROM=$( ask 'Enter value for --from' ) || exit
CREDITS=$( ask 'Enter value for --credits' ) || exit
CAPACITY=$( ask 'Enter value for --capacity' ) || exit
LY_PER=$( ask 'Enter value for --ly-per' ) || exit
trade.py run --from "$FROM" --credits "$CREDITS" --capacity "$CAPACITY" --ly-per "$LY_PER"
Regards,
H
- Once you've got the ask function working, you could only ask for the password (the above example looks like it asks for parameters to run python or something, all you'd need is the ask).
Run the whole script in a terminal
If you could have it run in a terminal then read
should work.
Get automator to ask you for more input
Apparently this question on apple.stackexchange.com looks there's a way to have automator "Ask for text" to try getting another variable.
edited Feb 13 at 12:10
answered Feb 7 at 3:44
Xen2050Xen2050
11k31536
11k31536
Thanks Xen. How would I enter all of this into a single Automator script (or two separate scripts, one for the zipping, and one for password protecting)? Much appreciated.
– Harry
Feb 11 at 0:01
If you're using zip, I think it has to compress and password in the same (single) command. But you'd just put theread ...
command before the for loop, putting it inside the for loop would read a password for each file (if you wanted different passwords). I'll edit it all together at the end of my answer. PS If the answer's useful or the "best" then please do accept it &/or vote it up, thanks :)
– Xen2050
Feb 11 at 7:22
Thanks Xen, I couldn't get the above scripts to work, what I ended up doing was setting the pass variable in the script. See:pass=password for f in "$@" do zip -j -e -P "$pass" "$f.zip" "$f" done
Thanks.
– Harry
Feb 13 at 2:52
That works too, and no typing errors either. I think I see the problem, your script isn't running in a regular terminal, so can'tread
from standard input... I'll edit in an idea or two.
– Xen2050
Feb 13 at 11:56
add a comment |
Thanks Xen. How would I enter all of this into a single Automator script (or two separate scripts, one for the zipping, and one for password protecting)? Much appreciated.
– Harry
Feb 11 at 0:01
If you're using zip, I think it has to compress and password in the same (single) command. But you'd just put theread ...
command before the for loop, putting it inside the for loop would read a password for each file (if you wanted different passwords). I'll edit it all together at the end of my answer. PS If the answer's useful or the "best" then please do accept it &/or vote it up, thanks :)
– Xen2050
Feb 11 at 7:22
Thanks Xen, I couldn't get the above scripts to work, what I ended up doing was setting the pass variable in the script. See:pass=password for f in "$@" do zip -j -e -P "$pass" "$f.zip" "$f" done
Thanks.
– Harry
Feb 13 at 2:52
That works too, and no typing errors either. I think I see the problem, your script isn't running in a regular terminal, so can'tread
from standard input... I'll edit in an idea or two.
– Xen2050
Feb 13 at 11:56
Thanks Xen. How would I enter all of this into a single Automator script (or two separate scripts, one for the zipping, and one for password protecting)? Much appreciated.
– Harry
Feb 11 at 0:01
Thanks Xen. How would I enter all of this into a single Automator script (or two separate scripts, one for the zipping, and one for password protecting)? Much appreciated.
– Harry
Feb 11 at 0:01
If you're using zip, I think it has to compress and password in the same (single) command. But you'd just put the
read ...
command before the for loop, putting it inside the for loop would read a password for each file (if you wanted different passwords). I'll edit it all together at the end of my answer. PS If the answer's useful or the "best" then please do accept it &/or vote it up, thanks :)– Xen2050
Feb 11 at 7:22
If you're using zip, I think it has to compress and password in the same (single) command. But you'd just put the
read ...
command before the for loop, putting it inside the for loop would read a password for each file (if you wanted different passwords). I'll edit it all together at the end of my answer. PS If the answer's useful or the "best" then please do accept it &/or vote it up, thanks :)– Xen2050
Feb 11 at 7:22
Thanks Xen, I couldn't get the above scripts to work, what I ended up doing was setting the pass variable in the script. See:
pass=password for f in "$@" do zip -j -e -P "$pass" "$f.zip" "$f" done
Thanks.– Harry
Feb 13 at 2:52
Thanks Xen, I couldn't get the above scripts to work, what I ended up doing was setting the pass variable in the script. See:
pass=password for f in "$@" do zip -j -e -P "$pass" "$f.zip" "$f" done
Thanks.– Harry
Feb 13 at 2:52
That works too, and no typing errors either. I think I see the problem, your script isn't running in a regular terminal, so can't
read
from standard input... I'll edit in an idea or two.– Xen2050
Feb 13 at 11:56
That works too, and no typing errors either. I think I see the problem, your script isn't running in a regular terminal, so can't
read
from standard input... I'll edit in an idea or two.– Xen2050
Feb 13 at 11:56
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1402096%2fpassword-protect-multiple-individual-zip-files-on-mac%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
How would you tell zip the password? Should it be the same for every file, or should it be a keyfile/passphrase-file?
– Xen2050
Feb 5 at 10:34
Hi @Xen2050, the password should be the same for every file.
– Harry
Feb 6 at 19:56