我尝试删除我可以在folderPath. 但我只想删除名称为“Jenkins”的那个。
如何在列表中定义仅删除该文件。?
示例:
在 C:\test\test 中有 3 个文件,要删除名称中包含 Jenkins 的文件:
import groovy.io.FileType
String folderPath = "C:\\test" + "\\" + "test"
def list = []
def dir = new File("$folderPath")
dir.eachFileRecurse (FileType.FILES) { file ->
list << file
}
list.each {
println it.findAll() == "Jenkins" // Just files witch include in list "Jenkins" name
}
Run Code Online (Sandbox Code Playgroud)
感谢您的提示!