Return to Snippet

Revision: 5312
at February 27, 2008 12:51 by karelklic


Initial Code
import java.util.zip.*

def processZip(file) {
  try {
    zf = new ZipFile(file.toString())
    for (entries = zf.entries(); entries.hasMoreElements();) {
      zipEntryName = entries.nextElement().getName()
      if (zipEntryName ==~ /.*yaml$/ || zipEntryName ==~ /.*yml$/) 
        println file.toString() + ": " + zipEntryName
    }
    zf.close()
  } catch (ZipException e) {
    println "ERROR: " + file.toString() + " is problematic zip!"
  }
}

new File(".").eachFileRecurse() { f ->
  if (!f.isFile()) return
  if (f.toString() ==~ /.*zip$/) {
    processZip(f)
    return
  }
  println "ERROR: " + f.toString() + " is not a zip file"
}

Initial URL

                                

Initial Description

                                

Initial Title
Lists all zip files containing any yaml file; also lists all invalid zip files and non-zip files in a directory tree

Initial Tags

                                

Initial Language
Groovy