Created
December 22, 2017 09:44
-
-
Save nemo-kaz/6990e0fd2f8e9410a823fd5ff50796db to your computer and use it in GitHub Desktop.
Recursively find encrypted zip file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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