I have a working script that lists all the PDF files in a directory. It works as desired, but all I need is actually the file name of the first pdf file. Then I want to break up eachFileMatch(), because there can be thousands of PDF files in a directory.
I tried to use findfrom this Disconnect from groovy every closing after eachFileMatch().find, but didn't workCaught: groovy.lang.MissingMethodException: No signature of method: java.io.File.eachFileMatch() is applicable for argument types: (java.util.regex.Pattern) values: [.*.(?i)pdf]
def directory="c:\\tmp" // place 2 or more pdf files in that
// directory and run the script
def p = ~/.*.(?i)pdf/
new File( directory ).eachFileMatch(p) { pdf ->
println pdf // and break
}
Can someone give me an idea how to do this?
source
share