Groovy批处理命令

文件中被注释的代码一个获取MD5,另一个是过滤出包名 批量删除应用

test.groovy

class test {

    public static void main(String[] args) {
        def file = new File("C:\\Users\\Administrator\\Desktop\\screen\\test")
        file.listFiles().each{ subFile ->
//            println "certutil -hashfile ${subFile.name} MD5".execute().text

            if (subFile.name.endsWith("apk")) {
                println "adb install ${subFile.name}".execute().text
//                def segment = subFile.name.split("-")
//                def packageName = segment[segment.length-2]
//                "adb uninstall ${packageName} ".execute()
            }
        }
    }
}

运行命令:

groovy test.groovy


C:\Users\Administrator\Desktop\screen\test下文件

3D-Tech-locker.theme.l400000057-release.apk
Bear-locker.theme.l400000056-release.apk
City-Neon-locker.theme.l400000052-release.apk
Crocodile-locker.theme.l400000044-release.apk
Dusk-locker.theme.l400000045-release.apk
Falling-Flower-locker.theme.l400000051-release.apk
Fresh-Fruit-locker.theme.l400000050-release.apk
'Living Hummingbird-locker.theme.l400000055-release.apk'
Moto-Surfing-locker.theme.l400000046-release.apk
Parrots-locker.theme.l400000039-release.apk
Pink-Valentine-locker.theme.l400000058-release.apk
Rose-Valentine-locker.theme.l400000059-release.apk
Shore-locker.theme.l400000047-release.apk
test.groovy
Valentine-Rose-locker.theme.l400000060-release.apk
Winter-Glacier-locker.theme.l400000053-release.apk

相关文章

背景:    8月29日,凌晨4点左右,某服务告警,其中一个...
https://support.smartbear.comeadyapi/docs/soapui/steps/g...
有几个选项可用于执行自定义JMeter脚本并扩展基线JMeter功能...
Scala和Java为静态语言,Groovy为动态语言Scala:函数式编程,...
出处:https://www.jianshu.com/p/ce6f8a1f66f4一、一些内部...
在运行groovy的junit方法时,报了这个错误:java.lang.Excep...