10.4: List contents of .zip archives with Automator

Aug 01, '06 07:30:04AM

Contributed by: jvr

After writing this hint about testing .zip archives with Automator, I realized I could create a similar workflow to view the contents of an archive without having to decompress it.

This workflow creates a list of files contained within a .zip archive (along with file size in bytes and modification date and time). It then saves the list to a text file and opens the file for viewing. It also filters out the files contained within an invisible __MACOSX directory (including all the files with a ._ at the beginning), as they clutter the list and I am not interested in those items.

To create the workflow, open Automator and add the following actions, in the order shown:

  1. Finder Library -> Get Selected Finder Items.
  2. Automator Library -> Run Shell Script. Set the 'Shell' pop-up to /bin/bash, the 'Pass Input' pop-up to as arguments, and the actual command to unzip -l "$@". The -l flag tells unzip to list the contents of the archive without actually decompressing it.
  3. TextEdit Library -> Filter Paragraphs. Set the 'Return paragraphs that' pop-up to do not contain, and enter __MACOSX in the text box. (This step is optional; it will remove the invisible ._ files from your list.)
  4. TextEdit Library -> New Text File. I set 'Save as' to Temp Archive List.txt and 'Where' to Desktop. Alternatively, you could select 'Show Action When Run' under 'Options' to specify the file name and/or location when the workflow runs.
  5. Finder Library -> Open Finder Items. Leave the 'Open with' pop-up set to Default Application, or set it to your preferred text editor.
To use the workflow, save it as a plug-in for Finder (I saved mine as List Archive Contents). Then, when you need to know what files are in a .zip archive, but do not want to decompress it, just control-click (or right-click) on the archive and select Automator -> List Archive Contents from the contextual menu.

One thing to note: If you have filtered out the files in the __MACOSX directory, as I describe, the number of files listed will differ from the total given at the bottom of the list.

Comments (14)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20060728110724423