Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@nemo-kaz
Created December 22, 2017 09:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nemo-kaz/6990e0fd2f8e9410a823fd5ff50796db to your computer and use it in GitHub Desktop.
Save nemo-kaz/6990e0fd2f8e9410a823fd5ff50796db to your computer and use it in GitHub Desktop.
Recursively find encrypted zip file
// run findEncryptedZipFile.groovy in the root directory of Encrypted zip files
// to find out encrypted zip files recursively.
// run this code at the top directory of zip files.
// Output directory is d:\WORK\ENCRYPTED, modify the location to meet your environmnet
// Using maven https://mvnrepository.com/artifact/net.lingala.zip4j/zip4j
@Grapes(
@Grab(group='net.lingala.zip4j', module='zip4j', version='1.3.2')
)
import net.lingala.zip4j.core.ZipFile;
import net.lingala.zip4j.exception.ZipException;
new File(".").eachFileRecurse { file ->
if(file.isFile() && (file.name.toUpperCase().endsWith(".ZIP")))
{
curName = file.getPath().replaceAll(/.\\(.*)/) {m0,m1 -> m1}
String source = curName
try {
ZipFile zipFile = new ZipFile(source)
if (zipFile.isEncrypted()) {
println "move \"" + source + "\" \td:\\WORK\\ENCRYPTED "
}
} catch (ZipException e) {
println "Zip Exception e " + source
} catch (Exception e1) {
println "Exception e1 " + source
e1.printStackTrace()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment