Need to open a password protected zip on Mac OSX?

Recently we were sent a password protected zip file at work. If you have ever tried to double click open a protected zip file you know that you will get an error not a password prompt.

If we ignore third party applications to open these files we are left with running the unzip command from terminal. You can use the option “-P password” where you replace the word password with actual password used to protect the file. An example command might look like:

This may have been good enough for me. But we have less technically inclined folks in our group who needed access to the provided files. So I made an Automator that everyone in the group could reuse for even future files. The Automator needed several features.

  1. Provide a GUI browser selection box to choose the protected zip file.
  2. Prompt for the password needed to unzip the file.
  3. Send the content to the user’s desktop regardless of whom ran it.

Here is how we build the Automator. The key components are the use of variables within Automator and a shell script object that takes the file and password as arguments that were provided by the user.

Ask for Finder Items

  1. First drag over an Ask for Finder Items action from the “Files & Folders” section.
  2. We change the prompt to “Choose a zip file:”

Set Value of Variable

  1. Next drag over a “Set Value of Variable” action from the “Utilities” section.
  2. Click and change the variable name to “zipfile”

Ask for Text

  1. Next drag over an “Ask for Text” action from the “Text” section.
  2. Right click in the action title area next to “Ask for Text” and choose “Ignore Input.”
  3. Enter “Please paste or enter the password for the file:” into the Question box.
  4. Check the box for “Require an answer.”

Set Value of Variable

  1. Next drag over another “Set Value of Variable” action from the “Utilities” section.
  2. Click and change the variable name to “password”

Get Value of Variable

  1. Next drag over a “Get Value of Variable action from the “Utilities” section.
  2. Right click in the action title area next to “Get Value of Variable” and choose “Ignore Input.”
  3. Choose the variable box to retrieve the variable password.

Get Value of Variable

  1. Next drag over a “Get Value of Variable action from the “Utilities” section.
  2. Choose the variable box to retrieve the variable zipfile.

Run Shell Script

  1. Next drag over a “Run Shell Script” action from the “Utilities” section.
  2. Change the pass input to “as arguments.”
  3. Change the shell script to the following content:

    unzip -P $1 "$2" -d ~/Desktop

Now you can save the Automator as an Application. Maybe name it Unzipper. Now when you double click that “application” it will prompt you to select the desired zip file, enter the password and the output will show up in a folder on your desktop.

Here is the screen shot of the automator flow.

Unzip Automator
Uploaded with Skitch!
Share