How can use array to imitate repeated individual instances?
Do you mean like this:

def searchDir = ["z:/pathA/pathB","z:/pathA/pathQ"]
searchDir.each { d -&gt;
    new File( d ).eachFile {
        if (it.isFile()) {
            outfile.append( "$it.name\n" )
        }
    }
}