Peek into zip archives

Today's Best Tech Deals

Picked by Macworld's Editors

Top Deals On Great Products

Picked by Techconnect's Editors

Do you download lots of stuff from MacUpdate and VersionTracker ? Or do you receive collections of files from far-flung coworkers? In many cases, the files you receive will be compressed with the zip compression algorithm—especially as this is the what OS X 10.4’s Finder uses when you choose the Create Archive contextual menu item. Sometimes it’d be nice to look into these archives before you expand them. Perhaps a coworker accidentally sent you 1,500 files instead of 150, or you’d like to see the structure of an archive before you choose to expand it.

You can do this using third party tools, such as Stuffit Deluxe or Springy. These programs install tools to peek inside zip (and other) archives without expanding them. But you can also create your own solution for free, using nothing more than programs included with 10.4.

Start by launching Automator, in /Applications. We’re going to create a fairly simple four-step Automator workflow that will list the contents of zip archives without actually expanding them. The Automator window is split into three main sections—a Library column, an Action column, and a blank work area to the right. To build actions in Automator, you first select a Library, then you drag an entry from the Action column into the work area. Here are the four steps you need to create for this workflow. Drag each specified Action to the work area, in the order shown:

  1. Finder Library, Get Selected Finder Items Action.
  2. Automator Library, Run Shell Script Action. Set the Shell pop-up to /bin/bash, the Pass input pop-up to as arguments, and then enter this command in the blank work area within the action:
    unzip -l "$@" > ~/Desktop/zip_peek.txt

    Feel free to replace the path and filename with your own preferences, but don’t change anything to the left of that section. What you’ve just done is enter a Unix command, unzip, which will examine the contents of the selected Finder item. Here’s how it works. The -l bit tells unzip to just list the archive’s contents, not actually extract them. The ”$@” piece passes the name of the Finder item, surrounded by quotes (in case the filename includes spaces). The > sign simply routes the output of the previous command to the specified file, instead of routing it to the default output device (the screen, typically). Finally, the path to the file itself is provided (the ~ is a shortcut for /Users/your_username ).

  3. Finder Library, Get Specified Finder Items Action. Now things get a bit tricky. In order to specify the file that the previous step creates, we need to be able to point to it in a File Open dialog. However, since we haven’t run the script yet, it doesn’t yet exist. To solve that, switch to Terminal and type touch ~/Desktop/zip_peek.txt. (Alternatively, you could use TextEdit to create a file with a few characters in it, then save it as specified.) This will create an empty file in the proper location. Now switch back to Automator, click the + sign on the Get Specified Items window in the workflow area, and navigate to the file you just created.
  4. Finder Library, Open Finder Items Action. Leave the Open With pop-up set to Default Application.

That’s it for the workflow. When it’s all set up, it should look about like this:

To put your new workflow to use, select File -> Save as Plug-in. In the dialog that appears, enter a name for your workflow ( Show Zip Contents , perhaps), and make sure the Plug-in for pop-up is set to Finder, then click Save.

That’s it; you’re done. To use your new zip previewer, first select any zip archive in the Finder. Then control-click on it and choose Automator -> Show Zip Contents from the contextual menu. Note that this workflow can only be used on one file at a time—it won’t work if you have two or more zip archives selected. Also, feel free to delete the zip_peek.txt file when you’re done with it. It does not need to exist at all times (it just had to exist when we were creating the workflow). If it doesn’t exist when you run the workflow, it will be automatically created.

Update: Edited to list the correct location of Automator in the Applications folder.

Note: When you purchase something after clicking links in our articles, we may earn a small commission. Read our affiliate link policy for more details.
Shop Tech Products at Amazon