Monday, June 11, 2012

Unzip many .zip files with Cygwin

Someone gave me a directory of compressed text files that had been compressed using the built in Windows zip program. That's a terrible idea for two reasons:

  1. A bunch of separate .zip files will not compress as efficiently as one .zip file with all the text files inside of it.
  2. Windows has no built in faculty for unzipping a bunch of files.
Bandwidth is cheap, so I'm ignoring the first point for now. How can I quickly and easily unzip a bunch of .zip files? Using Cygwin. Cygwin is a *nix shell that sits on top of Windows, and it works spectacularly. You also have to install the unzip program for Cygwin, gunzip won't work.

Here's a tricky gotcha:

$ unzip *.zip
Archive:  blah1.zip
caution: filename not matched:  blah2.zip
caution: filename not matched:  blah3.zip
caution: filename not matched:  blah4.zip
caution: filename not matched:  blah5.zip

Doesn't work. I Googled around, and here's the trick:

$ unzip \*.zip

You have to use the \ in front of the * in order for unzip to figure out the wildcard. Now I have a bunch of text files to process. 

No comments:

Post a Comment